Maintaining a list

Karl Pflästerer sigurd at 12move.de
Sat Feb 14 02:23:06 CET 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