0
Why's the code not breaking?
I'm new to python, I've been working on a guessing game where while loop should break after the user input the same number as the random number displayed. But it's not stopping and I don't know what I'm doing wrong. Please help https://code.sololearn.com/co0XtNHuAi8h/?ref=app
5 Answers
+ 7
Because the input is a string, and the number generated by random.randint is an integer.
You should use int(input()) instead of input()
Like this:
user_number = int(input("Please enter in a number beetween 1 and 3: "))
+ 4
You didn't convert the input to int. What user_number holds is a string.
+ 1
Thanks guys, it worked! :D
0
one of your "<"
should be ">"
0
Hi, first of all make sure that line 5 of your code will give you an integer (user_number must be an integer)
Second you can use if, elif instead of consecutive if statements
Then you have to update variable begin to reach to 5 (begin+=1)