Can this be done with list comprehension?
_karlo_ at _mosor.net_
Sun Jun 8 00:31:25 CEST 2008
This is what I'm trying to do (create a list using list comprehesion, then
insert new element at the beginning of that list):
result = [someFunction(i) for i in some_list].insert(0, 'something')
But instead of expected results, I get None as `result`. If instead of
calling `insert` method I try to index the list like this:
result = [someFunction(i) for i in some_list]
It works as expected. Am I doing something wrong, or I can't call list
methods when doing list comprehension?
In case you're wondering, it has to be done in one line ;).
_______ Karlo Lozovina - Mosor
| | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
| || _ | _ | Parce mihi domine quia Dalmata sum.
More information about the Python-list