I ran the following code: def xx(nlist): print("begin: ",nlist) nlist+=[999] print("middle:",nlist) nlist=nlist[:-1] print("final: ",nlist)
u=[1,2,3,4] print(u) xx(u) print(u) and obtained the following result: [1, 2, 3, 4] begin: [1, 2, 3, 4] middle: [1, 2, 3, 4, 999] final: [1, 2, 3, 4] [1, 2, 3, 4, 999] As beginner I couldn't understand why the last line wasn't [1, 2, 3, 4]. Could someone kindly help? M. K. Shen -- http://mail.python.org/mailman/listinfo/python-list