K
Karlo Lozovina
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][0]
It works as expected. Am I doing something wrong, or I can't call list
methods when doing list comprehension?
P.S.
In case you're wondering, it has to be done in one line .
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][0]
It works as expected. Am I doing something wrong, or I can't call list
methods when doing list comprehension?
P.S.
In case you're wondering, it has to be done in one line .