List problem

Jon Cosby jcosby at mindspring.com
Sun Mar 31 11:56:09 EST 2002


"Peter Hansen" <peter at engcorp.com> wrote in message
news:3CA7321A.DF13361A at engcorp.com...
> Jon Cosby wrote:
> >
> > This is strange. I've added some lines to see where this is failing.
> > You can see below the interpreter is not detecting matches, but they
> > are there, and it is showing them. There is something in
> > word[0] == firstword[i] that's not right or the interpreter isn't
> > understanding. What could possibly be wrong with this?
>
> Well, there's certainly nothing wrong with that, so it must be
> something else's understanding that is wrong... <wink>
>
> > for word in words:
> >    for i in range(lword):
> >       l.append(word[0] + ":" + firstword[i])
> >       if word[0] == firstword[i]:
> >          cols[i].append(word)
> > [...]
> > C:\Python21>python projects\wordsquare.py
> > Enter first word (enclosed in quotes): "add"
> > 502
> > [[], [], []]
> > ['A:a', 'A:d', 'A:d', 'A:a', 'A:d', 'A:d', 'A:a', 'A:d', 'A:d', 'A:a',
> > 'A:d', 'A:d', 'A:a', 'A:d', 'A:d', 'A:a', 'A:d', 'A:d', 'A:a', 'A:d',
'A:d',
>
> Are you sure you aren't forgetting case-sensitivity?  I still
> don't really understand your code, but I get a sense from the
> above that you are expecting "AWORD" to equal "aword", which
> is not the case (no pun intended).
>
> If this is true, try using word[0].upper() == firstword[i].upper().
>
> -Peter

Ouch! That's embarassing. Thanks for pointing it out.

Jon





More information about the Python-list mailing list