0

I have this code:

num = int(input("Enter a number: ")
if num%2 == 0:
    print("The number is even")

else:
    print("The number is odd")

Why do I get a syntax error on the if statement line?

1

2 Answers 2

0
num = int(input("Enter a number: "))
if num%2 == 0:
    print("The number is even")

else:
    print("The number is odd")enter code here

Missing a ) on the line before. Lots of times when you get syntax errors on a line it happens at that line or a line or a few lines before that, in your case it's looking for a matching paren.

Sign up to request clarification or add additional context in comments.

1 Comment

Whoops, didn't notice that, thanks for the quick response!
-2

As stated by @mikeb, the error in on the previous line, where
num = int(input("Enter a number: ") should be
num = int(input("Enter a number: ")).
When you are looking for an error, always check the previous line as well.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.