[Tutor] Problem with if statements and else statements

boB Stepp robertvstepp at gmail.com
Sat May 27 20:14:59 EDT 2017


Hello Jalen!

On Sat, May 27, 2017 at 4:19 PM, Jalen Barr <jalenbarr1 at gmail.com> wrote:
>
> In this code it always changes the PlaceHolder to 0 no matter what Month is
> set to
>
> Month ="September"
>
> if Month == "January" or "1":
>     PlaceHolder = 0

This must be written as:

if Month == "January" or Month == "1":
    PlaceHolder = 0

The way you wrote it is interpreted as:

if (Month == "January") or ("1"):
    PlaceHolder = 0

Hopefully you will see why you got the result you obtained.



-- 
boB


More information about the Tutor mailing list