237,295 views
21 votes
21 votes
why is this not working out? I'm confused I thought that because it was a "guess.isdigit()" it would only continue if i was a number??

why is this not working out? I'm confused I thought that because it was a "guess-example-1
why is this not working out? I'm confused I thought that because it was a "guess-example-1
why is this not working out? I'm confused I thought that because it was a "guess-example-2
User Anjisan
by
2.3k points

2 Answers

7 votes
7 votes

Answer:

Because guess is not converted to int

Step-by-step explanation:

try adding line "guess = int(guess)" between lines "if guess.isdigit():" and "print("That's Correct!")"

User Juvanis
by
3.3k points
14 votes
14 votes

This is because input() returns data of type string. Arithmetic operations cannot be performed between different types. Just replace the first line with this and your problem will be solved.

  • guess = int(input("Guess a number between 1 and 10: "))
User EllipticalInitial
by
2.8k points