I ran the attached program and got the following output:

[1, 2, 3]
[3, 6, 9]

I don't understand why the modification doesn't work in the case of
test() but does work in the case of test1().

Thanks for your help in advance.

M. K. Shen

------------------------------------------------------------

def test(alist):
  alist=[3,6,9]
  return

def test1(alist):
  alist[0],alist[1],alist[2]=3,6,9
  return

ss=[1,2,3]
test(ss)
print(ss)
test1(ss)
print(ss)
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to