Reputation: 3
I keep getting an "invalid syntax" message when I try to run this program. It highlights "age" in red after the "else" statement. I'm not sure what I did wrong.
age = float(input('How old are you? '))
citizen = float(input('How long have you been an American citizen? '))
if age >= 30 and citizen >= 9:
print('You are eligible to become a US Senator and a House Representative!')
else age < 30 >= 25 and citizen < 9 >= 7:
print('You are only eligible to become a House Representative.')
if age < 25 or citizen < 7:
print('You are not eligible to become a US Senator or a House Represenatative.')
Upvotes: 0
Views: 874
Reputation: 57470
The else
in else age < 30 >= 25 and citizen < 9 >= 7:
should be changed to elif
.
Upvotes: 0
Reputation: 309919
else age < 30 >= 25 and citizen < 9 >= 7:
is a syntax error. You can't have anything other than a :
after an else
statement.
Maybe you wanted an elif
clause1?
elif 30 > age >= 25 and 9 > citizen >= 7:
...
1Note that I also had to switch around your values a bit to make sense of the operator chaining that you were doing ...
Upvotes: 4