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.

15th Jul 2024, 7:01 AM
Aleksandar Sto
Aleksandar Sto - avatar
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" ?
15th Jul 2024, 8:07 AM
Bob_Li
Bob_Li - avatar
+ 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}")
15th Jul 2024, 7:28 PM
Harimamy Ravalohery
Harimamy Ravalohery - avatar