158k views
3 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

2 Answers

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 Aelkz
by
3.4k points
5 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 Gabrielhpugliese
by
3.6k points