+ 1
Can any one help me to correct this code. ( age group) chill : 0 to 11. Teen : 12 to 17. Adult: 18 to 64.
age = int(input()) if ( age > 0 ) and ( age <= 11): print("chill") elif ( age >= 12 ) and ( age <= 17): print("Teen") elif ( age >= 18 ) and ( age <= 64): print("Adult") else: print ()
15 Antworten
0
2 different options for you here.
age = int(input())
if age >= 0 and age <= 11:
print("chill")
elif age >= 12 and age <= 17:
print("Teen")
elif age >= 18 and age <= 64:
print("Adult")
#or
if 0 <= age <= 11:
print('chill')
elif 12 <= age <= 17:
print('Teen')
elif 18 <= age <= 64:
print('chill')
0
Rik Wittkopp
I try like this but the problem is test case #4 and test case #5 is not work yet
Can I do another way
0
Abdul Latiif
Check your outputs to ensure they match the requirements of the challenge.
I note that Teen & Adult start with capitals.
chill does not, also I suspect it should be Child.
The problem may be in the details, not the logic
0
Rik Wittkopp
Here is details
Given the age of a person as an input, output their age group.
Here are the age groups you need to handle:
Child: 0 to 11
Teen: 12 to 17
Adult: 18 to 64
Sample Input
42
Sample Output
Adult
0
Abdul Latiif
Child is your problem.
You have chill
PS: Put @ in front of a name to mention them.
It sends a ping to the person
0
Manav Roy
Thank you !
Here is correct code
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 ()
0
Manav Roy
Because when I run test case #4 and test case #5 are lock and their is some wrong in the code .
I checked several time but I do not get it but you get it the point.
0
Manav Roy
Yes I get it and I solved it already.
0
Hi,
This works prefectly.
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")
0
Darren Sheriff
You Right but age doesn't equal to zero ok check and correct it
age > 0 correct
age >= 0 wrong
I hope you understand it
0
OK, it worked alright on the task I completed and allowed me to move on👍🏻
But I can see your logic and will definitely take that on board. 🙏🏻
Thanks for you input.
0
Darren Sheriff
You welcome!!