Ask coding questions

← Back to all posts
What is the problem?
Oscarphil

Sorry I'm new and I don't know what is the problem here (the name of the variable is in french):

reponse=0

reponse = input("Vous trouvez une \033[1;31mbaie rouge" + " la manger?")
if reponse == 1:
food = random.randint(1, 30)
nourriture = nourriture + food
print("something")

Answered by JustCoding123 [earned 5 cycles]
View Answer
Voters
Oscarphil
Comments
hotnewtop
JustCoding123

If the problem is that the if statement never runs it's because you are comparing a string with an int. To fix it change it to reponse == "1".

Oscarphil

@JustCoding123 OK thanks

JustCoding123

@Oscarphil Can you mark my answer as correct please?