Re: Why does the insert after list function fail?

2016-09-22 Thread Jussi Piitulainen
38016226...@gmail.com writes:

> A=["1","2","3"]
> print(list(map(float,A)).insert(0,1))
>
> I want to insert 1 at the head of the list but this gives me a surprise

Is it the same surprise that you get from print([1,2,3].insert(0,1))?

Or the more advanced surprise from print(A.insert(0,1))?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does the insert after list function fail?

2016-09-22 Thread Wildman via Python-list
On Thu, 22 Sep 2016 12:29:12 -0700, 380162267qq wrote:

> A=["1","2","3"]
> print(list(map(float,A)).insert(0,1))
> 
> I want to insert 1 at the head of the list but this gives me a surprise

I am not certain about what you are doing so I might be way off here.
The following will insert 1 at the head of the list...

Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> A=["1","2","3"]
>>> list.insert(A,0,"1")
>>> print(A)
['1', '1', '2', '3']

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does the insert after list function fail?

2016-09-22 Thread John Gordon
In <39ec91a8-eeae-489f-9237-9d9a481a8...@googlegroups.com> 
38016226...@gmail.com writes:

> A=["1","2","3"]
> print(list(map(float,A)).insert(0,1))

> I want to insert 1 at the head of the list but this gives me a surprise

insert() does not return anything; it modifies the existing list in-place.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

-- 
https://mail.python.org/mailman/listinfo/python-list


Why does the insert after list function fail?

2016-09-22 Thread 380162267qq
A=["1","2","3"]
print(list(map(float,A)).insert(0,1))

I want to insert 1 at the head of the list but this gives me a surprise
-- 
https://mail.python.org/mailman/listinfo/python-list