On 11/1/2010 1:53 PM, Josep M. Fontana wrote:
Hi Dave,
On Mon, Nov 1, 2010 at 2:38 PM, Dave Angel<da...@ieee.org> wrote:
(You top-posted, so I had to remove the out-of-order earlier portion.)
I've not tried to run the code, but I think I can see the problem. Since
you never assign 'year' inside the loop(s), it's always the same. And it's
whatever the last value it had in the earlier loop.
The simplest cure would be to fix the outer loop
for name, year in name_year.items():
Alternatively, and maybe easier to read:
for name in name_year:
year = name_year[name]
Sorry about the top-posting. Sometimes it seems that a little
top-posting might make things easier (I hate to have to go through
long quotes) but you are totally right, netiquette is netiquette.
I'm still puzzled as to why that particular value was the one picked
up but what's important is that you provided the solution for the
problem in the loop. Now it works perfectly. Thank you very much!
Josep M.
The only time year is bound is in the previous loop, as I said. It's
the line that goes:
name, year = line.strip.....
So year is whatever it was the last time through that loop.
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor