+ 2
What is the error? (Simple If Else Question
Everything I try results in a error. No matter, if I try flif, else if or anything else. It says that line 5 has a error. Could you help me out with that? And please with explanation I want to learn. Thank you! <3 age = int(input()) if age <= 11: print("Child") elif age >= 12 and age < 18: print("Teen") elif age <= 64 and > 18: print("Adult") elif age > 64: print("Senior")
7 Antworten
+ 1
You where on the right way. But only the word "age" Was missing.
Look at this:
age = int(input())
if age <= 11:
print("Child")
elif age >= 12 and age < 18:
print("Teen")
elif age <= 64 and age > 18:
print("Adult")
elif age > 64:
print("Senior")
... AGE <= 64 and AGE > 18:
+ 4
elif age <= 64 and > 18: ???
Should it be:
elif age <= 64 and age > 18
+ 3
Coding Cat [Mouse searching]
age = int(input())
if age <= 11:
print("Child")
else if:
age >= 12 and age < 18
print("Teen")
else if age <= 64 and > 18
print("Adult")
else if age > 64:
print("Senior")
Now I removed the ":" after every statement, but it still show me a Syntax error in line 5
+ 3
Looks like you have > 18 and < 18. What happens if someone input is 18.
+ 2
No, dont remove the colon.
But add the word "age"
+ 2
Coding Cat [Mouse searching] Thank you so much!!! I tried so long to fix this bug.. such a simple mistake. I'll try to prevent myself from doing this mistake again
Also thank you to Paul ! You are so right something I didn't think of thank you
+ 1
And Paul is also right. Your condition for Adult should be
age >= 18 !! Not only >18.
Because if you only check <18 and >18, you get no result for age = 18.