A difficulty with lists
Mok-Kong Shen
mok-kong.shen at t-online.de
Mon Aug 6 15:50:13 EDT 2012
More information about the Python-list mailing list
Mon Aug 6 15:50:13 EDT 2012
- Previous message (by thread): Script to easily install eGenix PyRun in a target directory
- Next message (by thread): A difficulty with lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): Script to easily install eGenix PyRun in a target directory
- Next message (by thread): A difficulty with lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list