else Statement: Write a program to control entrance to a club. Only people who are 18 or older are allowed to enter the club. Yo | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

else Statement: Write a program to control entrance to a club. Only people who are 18 or older are allowed to enter the club. Yo

Write a program to control entrance to a club. Only people who are 18 or older are allowed to enter the club. Your program takes the age of the person who tries to enter, and outputs "Allowed" if they are allowed to enter the club, and "Sorry" if they are younger than the allowed age. my attempt: age = int(input()) age = 24 if age > 18: print("Allowed") if age <= 18: print("Sorry") Note: Test case 2 & 3 are not giving me the answer " Sorry" Please assist

27th Sep 2021, 6:08 PM
ntombizodwa
10 Answers
+ 4
age = int(input()) takes input but age = 24 #this cause to assign age to 24 for what ever the input value so this is not needed , remove this line if age > 18: #edit: also use >= here print("Allowed") if age <= 18: #this if block is idented inside if statement, never works according to logic you used, so move to outside of if block or just use else : (its equal, obviously according to your condition ) else: print("Sorry")
27th Sep 2021, 6:14 PM
Jayakrishna 🇮🇳
+ 2
/* Here it is */ age = int(input()) if age > 18 : print("Allowed") else : print("Sorry")
20th May 2022, 8:46 PM
Hamza Limam Eibba
Hamza Limam Eibba - avatar
+ 1
age = int(input()) age == 24 if age >= 18: print ("Allowed") else: print ("Sorry")
22nd Aug 2022, 11:39 AM
J K Vinoth S92084841
0
Thanks for the note
5th Feb 2022, 8:06 PM
Riad Kaptan
0
if age >= 18: print("Allowed") else: print("Sorry")
28th Mar 2022, 6:08 PM
UF.Rasna
UF.Rasna - avatar
0
age = int(input()) if age>=18: print("Allowed") else: print("Sorry")
29th Mar 2022, 2:45 AM
H.M.H.Prabhashani
0
age = int(input()) age == 24 if age >= 18: print ("Allowed") else: print ("Sorry")
29th Mar 2022, 1:45 PM
Abdelkhalek Nael Ahmad Allan
Abdelkhalek Nael Ahmad Allan - avatar
0
age = int(input()) if age > 18: print("Allowed") else: print("Sorry") #A and S should be capital
5th Oct 2023, 4:00 PM
B Charvi
B Charvi - avatar
- 1
age = int(input()) if age >= 18: print("Allowed") else: print("Sorry")
10th Jan 2022, 6:19 AM
Nethmi Muthugala
- 2
true answer age = int(input()) if age>=18: print("Allowed") if age<=18: print("Sorry")
25th Jan 2022, 12:42 PM
Riad Kaptan