Ask coding questions

← Back to all posts
help
NasR2 (0)

myclubs=["barca", "bayern", "juventus", "benfica"]
winner=input("please enter your beloved club" )
if winner in myclubs :
print(f"congratulaions for uls {winner} ")
can someone help me if condition does't work

Comments
hotnewtop
btfuss (177)

Well, the print(f"congratulations for you {winner}") isn't indented
It should look like this:

my clubs = ["barca, "bayern, "juventus, "benfica"]
winner = input("Please enter your beloved club")
if str(winner) in myclubs:
    print(f"Congratulations, {winner}")
NasR2 (0)

it doesn't work also

btfuss (177)

@NasR2 I found the error: I made a typo on line one, here is the fixed code:

myclubs = ["barca, "bayern, "juventus, "benfica"]
winner = input("Please enter your beloved club")
if str(winner) in myclubs:
    print(f"Congratulations, {winner}")
NasR2 (0)

thanks my friend for the effort but really i did not understand why it doesn't work if you add the other condition else it will print that contains else

btfuss (177)

@NasR2
Looks like it does work for me?
If you need to add an else statement, here is a template:

myclubs = ["barca", "bayern", "juventus", "benfica"]
winner = input("Please enter your beloved club")
if str(winner) in myclubs:
    print(f"Congratulations, {winner}")
else:
    print(f"Sorry, but {winner} is not a club")
NasR2 (0)

it will print the else condition only