Comparsion error [This sucks.]

Derek Thomson dthomson at NOSPAMusers.sf.net
Fri Mar 7 03:06:34 EST 2003


Tetsuo!

You'll probably get more and faster responses if you pick a more 
sensible subject!

Tetsuo wrote:
> No matter how much I look at my code, I can't see how 0>=10. I fixed a
> few things today, but the program still beyond fails.
> 
> Here's a link to the program:
> 
> http://hoverboarder.tripod.com/base.txt

Try adding this extra print statement to your debug output:

         print item, basein, baseout
         print type(item)

I get 'type<str>', meaning that 'item' is in fact a string containing 0, 
not the number 0. Do you understand the difference?

When you split the number variable on the "." string, you forgot to turn 
each of the resulting strings into integers.

In modern Pythons, you could change your "split" line to this:

numlist = [ int(num) for num in number.split(".") ]

... which calls the "int" conversion function on each number.

If you do this your program gets a lot further. You hit another bug 
right at the end, but that's your next problem, and isn't related to 
this one.

Regards,
Derek.





More information about the Python-list mailing list