>>> def hello(l):
k=l
k.append('s')
return l
>>> hello(['hello'])
['hello', 's']
Just a strange occurrence i found in python3.4.1 I'm sure it has a reason but I don't understand it.
>>> def hello(l):
k=l
k.append('s')
return l
>>> hello(['hello'])
['hello', 's']
Just a strange occurrence i found in python3.4.1 I'm sure it has a reason but I don't understand it.
append modifies the referenced object in-place, instead or returning a new one. Even if you type k=l, the append method will modify the underlying referenced list, so both k and l will have the value ['hello', 's']