Can this be done with list comprehension?

John Machin sjmachin at lexicon.net
Sat Jun 7 20:07:51 EDT 2008


On Jun 8, 8:31 am, Karlo Lozovina <_karlo_ at _mosor.net_> wrote:
> 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')

result = ['something'] + [someFunction(i) for i in some_list]



More information about the Python-list mailing list