'>' Not Supported Between Instances Of 'str' And 'int' In My Guess The Number Game
In my guess the number program it gives me the error: '>' not supported between instances of 'str' and 'int' on line 26 in main. I would be grateful if someone helped me with th
Solution 1:
By default, input
returns a string. You need to convert your input to a numeric type, in this case integer.
Replace:
guess = input("Guess a number: ")
With:
guess = int(input("Guess a number: "))
You may also wish to validate user input to ensure that you have actually been provided with a valid integer. For this you should see Asking the user for input until they give a valid response.
Post a Comment for "'>' Not Supported Between Instances Of 'str' And 'int' In My Guess The Number Game"