Your function is wrong, it

Your function is wrong, it is not changing the object pointed to by arg, it is assigning "arg" to a new object, leaving original unchanged.

Try this:

>>> l = ["original value"]
>>> def func(arg):
... arg.append("value added by func")
...
>>> print l
['original value']
>>> func(l)
>>> print l
['original value', 'value added by func']
>>>

Reply

The content of this field is kept private and will not be shown publicly.
Type this to prove you are human.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Ads (you can disable these if you log in)