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.

6th Jan 2022, 11:05 AM
Sasha Krömtz
9 Respuestas
+ 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.
6th Jan 2022, 12:06 PM
Bartek
+ 1
Invalid syntax in if age >= 0 and <= 11: #hope you find correct way And : missing after last else.
6th Jan 2022, 11:15 AM
Jayakrishna 🇮🇳
+ 1
Maybe becouse you forgot to ad : after else I think it should help (python hasn't got very good error messanges)
6th Jan 2022, 11:19 AM
Bartek
+ 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.
6th Jan 2022, 11:20 AM
Sasha Krömtz
+ 1
Sasha Krömtz You want clue and it is : if age >= 0 and <= 11: invalid syntax! What is 2 condition here? Incomplete one..
6th Jan 2022, 11:23 AM
Jayakrishna 🇮🇳
+ 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.
6th Jan 2022, 11:31 AM
Sasha Krömtz
+ 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
6th Jan 2022, 12:07 PM
Jayakrishna 🇮🇳
0
Omg guys i was so blind for this. Ahhahaha
6th Jan 2022, 12:08 PM
Sasha Krömtz
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")
3rd Dec 2023, 1:56 AM
emanoj