Can any one help me to correct this code. ( age group) chill : 0 to 11. Teen : 12 to 17. Adult: 18 to 64. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 ()

3rd Feb 2022, 5:55 AM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
12 Answers
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')
3rd Feb 2022, 6:46 AM
Rik Wittkopp
Rik Wittkopp - avatar
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
3rd Feb 2022, 7:24 AM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
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
3rd Feb 2022, 7:30 AM
Rik Wittkopp
Rik Wittkopp - avatar
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
3rd Feb 2022, 7:54 AM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
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
3rd Feb 2022, 8:39 AM
Rik Wittkopp
Rik Wittkopp - avatar
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 ()
4th Feb 2022, 10:53 AM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
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.
4th Feb 2022, 2:43 PM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
0
Manav Roy Yes I get it and I solved it already.
4th Feb 2022, 3:14 PM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
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")
4th Feb 2022, 4:12 PM
Darren Sherriff
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
4th Feb 2022, 4:32 PM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
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.
4th Feb 2022, 4:55 PM
Darren Sherriff
0
Darren Sheriff You welcome!!
4th Feb 2022, 5:49 PM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar