+ 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
12 Respostas
+ 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")
+ 2
/* Here it is */
age = int(input())
if age > 18 :
print("Allowed")
else :
print("Sorry")
+ 1
age = int(input())
age == 24
if age >= 18:
print ("Allowed")
else:
print ("Sorry")
0
Thanks for the note
0
if age >= 18:
print("Allowed")
else:
print("Sorry")
0
age = int(input())
if age>=18:
print("Allowed")
else:
print("Sorry")
0
age = int(input())
age == 24
if age >= 18:
print ("Allowed")
else:
print ("Sorry")
0
age = int(input())
if age > 18:
print("Allowed")
else:
print("Sorry")
#A and S should be capital
- 1
age = int(input())
if age >= 18:
print("Allowed")
else:
print("Sorry")
- 2
true answer
age = int(input())
if age>=18:
print("Allowed")
if age<=18:
print("Sorry")