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 equal to 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?)
EDIT: I first gave the wrong reason why this is not working. As others have pointed out,
is equivalent to
So
...always gets executed.You could use
or even better
or
instead.
Yet another way of getting the same result would be to use the
datetimemodule: