Why does the insert after list function fail?

Wildman best_lay at yahoo.com
Thu Sep 22 16:17:43 EDT 2016


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']

-- 
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!



More information about the Python-list mailing list