Sunday, February 13, 2011

Python always thinks my string is the highest possible number

Programmer Question

if month == 1 or 10:
month1 = 0
if month == 2 or 3 or 11:
month1 = 3
if month == 4 or 7:
month1 = 6
if month == 5:
month1 = 1
if month == 6:
month1 = 4
if month == 8:
month1 = 2
if month == 9 or 12:
month1 = 5


This code always returns month1 5. I'm quite new at programming, what am I doing wrong? (I guess it involves the fact that 12 is the highest number. But == means equals right?)



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails