Python Forum

Full Version: Invalid syntax using conditionals if - else
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I'm self-taught Python. I use version 3.9.
I wrote simple code to learn how to use the "if" and "else" conditionals, and they worked, but I tried to write more complex code, following my previous examples, and it indicates that there is a syntax error.
Could you help me identify and understand my mistake, please?

My_age = 33 
His_age = int (input ("Write your age: "))
print ("My age less yours is: ", My_age - His_age)
print ("My age plus yours is: ", My_age + His_age)
Question = int (input ("How many years old am I?")
if My_age == Question:
    print ("Correct")
else:
    print ("Incorrect")
Line 5 doesn't have balanced parentheses.