[Tutor] Variables don't change when altered within a loop?
Evan Klitzke
eklitzke at gmail.com
Fri Jun 30 00:43:34 CEST 2006
Hi, I just started picking up python yesterday, and have already come
across something that has me stumped. I want some code that does
this:
a = foo(a)
b = foo(b)
c = foo(c)
So I try to do this with a for loop, like so:
for i in [a, b, c]:
i = foo(i)
print i # make sure that it worked correctly
So far, so good. The problem is that outside the loop, the values
aren't changed. For example,
print [a, b, c] # outside the loop; the values never actually changed!
What is going on? Why aren't the values of my variables changing when
I change them inside a loop like this?
-- Evan
More information about the Tutor
mailing list