[newbie] A question about lists and strings
Mok-Kong Shen
mok-kong.shen at t-online.de
Fri Aug 10 05:19:36 EDT 2012
In an earlier question about lists, I was told about the issue of
creation of local names in a function. However, I still can't
understand why the program below outputs:
[999] sss
[999]
and not two identical lines of output. For both operators "+=" should
anyway work in similar manner in the function xx in my view.
Thanks for your help in advance.
M. K. Shen
----------------------------------------------------------
def xx(list,str):
list+=[999]
str+="sss"
lista=[]
stra=""
lista+=[999]
stra+="sss"
print(lista,stra)
listb=[]
strb=""
xx(listb,strb)
print(listb,strb)
More information about the Python-list
mailing list