0

PYTHON Else Statement: How to pass code coach test?

Write a program to control entrance to a club. Only people who are 18 or older are allowed to enter the club. The given program takes the age and the name of the person who tries to enter. Complete the program to output "Welcome" followed by the name of the person if they are allowed to enter the club, and "Sorry" if they are younger than the allowed age. My answer: age = int(input()) name = input() # your code goes here if age == 24: print ("Welcome Amy") elif age == 18: print ("Welcome John") else: print ("Sorry") The problem: Test Case 1-4 had a checkmark except the hidden test case 5. I am stuck in the question while searching the net and sololearn discussion posts. I kinda get it but I'm missing something. I will be thankful for the tips.

2nd Oct 2023, 2:15 AM
Twin Halloween
Twin Halloween - avatar
2 Réponses
+ 5
First of all you have to check wheather the user input is bigger than Or equal to or smaller than 18 means if it is bigger that Or equal to 18 the output should be "Welcome"+ name. Else the output should " sorry. #Taking age as an input age = int(input()) #Taking the person name name = input() #Checking the condition if it is bigger than Or equal to 18 if age >= 18: print(" Welcome "+name) else: print(" Sorry")
2nd Oct 2023, 2:28 AM
Gulshan Mahawar
Gulshan Mahawar - avatar
+ 2
Thanks! I got it. I tunneled on inputting the name of a person in my code. I forgot about the user input.
2nd Oct 2023, 2:40 AM
Twin Halloween
Twin Halloween - avatar