Maintaining a list

Karl Pflästerer sigurd at 12move.de
Fri Feb 13 20:23:06 EST 2004


On 14 Feb 2004, Karl Pflästerer <- sigurd at 12move.de wrote:

> So if you write:

Here something got lost during c&p

>>> def myfunc (item, lst = []):
...     lst.append(item)
...     return lst
... 

>>>> myfunc(1)
> [1]
>>>> myfunc(2)
> [1, 2]
>>>> myfunc(3)
> [1, 2, 3]

   KP

-- 
 He took his vorpal sword in hand:
     Long time the manxome foe he sought--
 So rested he by the Tumtum tree,
     And stood awhile in thought.  "Lewis Carroll" "Jabberwocky"



More information about the Python-list mailing list