0
I need help with the Task else Statement
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. Sample Input 24 James Sample Output Welcome James Thats my code and i really dont understand what´s wrong. agelimit = 18 age = int(input()) name = input() if age >= agelimit: print("Welcome" + name) else: print("Sorry" + name) Thanks for the help.
2 odpowiedzi
+ 2
try adding a space at the end of "Welcome" if you want to concatenate with +.
print("Welcome " + name)
or use a comma separator if you don't want to add a space.
print("Welcome", name)
Also, do you have to add a name to "Sorry" ?
+ 1
Yes, right its the space I think
Aleksandar Sto try this code to reduce the number of lines, and test it
age, name = int(input()), input()
print(f"Welcome {name}" if age>=18 else f"Sorry {name}")