1
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.

1
  • and =< 40 and what is smaller or equal to 40? Commented Nov 23, 2016 at 23:21

1 Answer 1

4

You probably meant to do this:

#             v mention `Q` here
if Q > 30 and Q <= 40:
#               ^ i.e. `<` before `=`
Sign up to request clarification or add additional context in comments.

5 Comments

Have you also changed =< to <=? The first option is not correct in python.
If you changed both, the syntax is then correct normally.
And actually, Python allows the very nice construct 30 < Q <= 40
OK that worked, I guess I hadn't changed it back to <= since I was fiddling with it to try and fix it.
why if Q > 30 and Q < 40: it only work if i add = ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.