0
Boolean logic age groups python
age = int(input()) if age >= 0 and <= 11: print("Child") elif age >= 12 and <= 17: print("Teen") elif age >= 18 and <= 64: print("Adult") else print("senior") I watched for the solution but everyone write the same and i still got syntax error. I need only the hint why this code recieves the message 'invalid syntax error' , line 3.
9 Answers
+ 4
Sasha Krömtz if you still doesn't know Jayakrishna🇮🇳 tried to say you need a variable before <= 11: becouse <=11 doesn't know whith what variable to compare it.
+ 1
Invalid syntax in
if age >= 0 and <= 11:
#hope you find correct way
And
: missing after last else.
+ 1
Maybe becouse you forgot to ad : after else I think it should help (python hasn't got very good error messanges)
+ 1
I add it but still the same. I have this solution silce over a day, and like every solution i was trying to find. Looks like mine, but i still have this 'invalid syntax error'. And bro really, i cant understand this.
+ 1
Sasha Krömtz You want clue and it is :
if age >= 0 and <= 11: invalid syntax!
What is 2 condition here? Incomplete one..
+ 1
Jayakrishna🇮🇳 my english isnt the best, but i think you writing the except code iam writing. And i already tried different versions, and i dont know what you trynna say to me.
+ 1
You can write in your own language..
I use google translate..
I said where is mistake. You have find correct way by revision the lesson.. Sasha Krömtz Do you want solution..? better, you to try again
0
Omg guys i was so blind for this. Ahhahaha
0
2 ISSUES:
1) You need to add "age" for each check you do:
2) The last ELSE is missing a colon.
The correct version would be as below:
age = int(input())
if age >= 0 and age <= 11:
print("Child")
elif age >= 12 and age <= 17:
print("Teen")
elif age >= 18 and age <= 64:
print("Adult")
else:
print("senior")