0
Boolean age group question: Why is this invalid syntax?
Im trying to do the Boolean age group challenge and it keeps saying line #9 is invalid syntax. What have I done wrong? age = int(input()) # your code goes here if age>0 and age<=11: print("Child") elif(age>=12 and age<=17): print("Teens") elif(age>=18 and age<=64): print("Adult") elif(age>64): print("Senior") https://code.sololearn.com/csoJUkN5cFQT/?ref=app
4 odpowiedzi
+ 5
If and elif statements have to be aligned vertically.
if condition:
print()
elif condition:
print()
0
age = int(input())
# your code goes here
if age>0 and age<=11:
print("Child")
elif(age>=12 and age<=17):
print("Teens")
elif(age>=18 and age<=64):
print("Adult")
elif(age>64):
print("Senior")
0
It is an indentation error
0
This also works perfectly:
age = int(input())
# your code goes here
if age>=0 and age<=11:
print("Child")
if age>=12 and age<=17:
print("Teen")
if age>=18 and age<=64:
print("Adult")
if age>=65:
print("Senior")