Reputation: 11285
>>> numlist = ['0', '1', '2', '3', '4', '5', '6']
>>> numlist = numlist.insert(0, '-1')
>>> numlist
>>> print numlist
None
>>>
I don't get it - I am trying to append to the first position of the list, and it is giving me a NoneType?
Upvotes: 3
Views: 159
Reputation: 117691
list.insert
modifies the list in-place and returns None
. Use it like this instead:
>>> numlist = ['0', '1', '2', '3', '4', '5', '6']
>>> numlist.insert(0, '-1')
>>> numlist
['-1', '1', '2', '3', '4', '5', '6']
Also, is there any particular reason you are using quoted numbers?
Upvotes: 9