Change one list item in place
Jean-Michel Pichavant
jeanmichel at sequans.com
Wed Dec 1 08:23:59 EST 2010
Gnarlodious wrote:
> This works for me:
>
> def sendList():
> return ["item0", "item1"]
>
> def query():
> l=sendList()
> return ["Formatting only {0} into a string".format(l[0]), l[1]]
>
> query()
>
>
> However, is there a way to bypass the
>
> l=sendList()
>
> and change one list item in-place? Possibly a list comprehension
> operating on a numbered item?
>
> -- Gnarlie
>
what about
def query():
return ["Formating only {0} into a string".format(sendList()[0])] +
sendList()[1:]
JM
More information about the Python-list
mailing list