Is 'everything' a refrence or isn't it?
KraftDiner
bobrien18 at yahoo.com
Wed Jan 4 13:54:17 EST 2006
I was under the assumption that everything in python was a refrence...
so if I code this:
lst = [1,2,3]
for i in lst:
if i==2:
i = 4
print lst
I though the contents of lst would be modified.. (After reading that
'everything' is a refrence.)
so it seems that in order to do this I need to code it like:
lst = [1,2,3]
for i in range(len(lst)):
if lst[i] == 2:
lst[i]=4
print lst
Have I misunderstood something?
More information about the Python-list
mailing list