[Tutor] Problems with partial string matching
Josep M. Fontana
josep.m.fontana at gmail.com
Mon Nov 1 18:53:32 CET 2010
Hi Dave,
On Mon, Nov 1, 2010 at 2:38 PM, Dave Angel <davea at 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.
More information about the Tutor
mailing list