Anonymous
Anonymous

Reputation: 39

Python comparing integers and using if

Q = int(input("Enter a number."))
if Q > 30 and =< 40:
    import easygui
    easygui.msgbox("This number is greater than 30 and less than or equal to 40")

I don't know what's wrong it just says "Invalid Syntax" and highlights the equal sign in equal to or less than 40 before even running the code. easygui isn't the problem.

Upvotes: 1

Views: 721

Answers (1)

Carles Mitjans
Carles Mitjans

Reputation: 4866

You probably meant to do this:

#             v mention `Q` here
if Q > 30 and Q <= 40:
#               ^ i.e. `<` before `=`

Upvotes: 4

Related Questions