append function problem?

vbgunz vbgunz at gmail.com
Fri Apr 28 02:12:08 EDT 2006


seed = [1,2,3]
seed.append(4)
print seed  # [1,2,3,4]

many of the list methods are in place methods on a mutable object. In
other words, doing the following results in None.

seed = [1,2,3]
seed = seed.append(4)
print seed  # None

you also just wiped out your list... The append method like many other
list methods simply return None. To get the value of an append, append
first then access later like so.

seed = [1,2,3]
seed.append(4)
print seed  # [1,2,3,4]




More information about the Python-list mailing list