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 this, Thank you.
import random
guesses = 0
def higher(guesses):
print("Lower")
gueeses += 1
def lower(guesses):
print("Higher")
guesses += 1
def correct(guesses):
print("You got it correct!")
print("It was {0}".format(number))
guesses += 1
def _main_(guesses):
print("Welcome to guess the number")
number = random.randint(1, 100)
while True:
guess = input("Guess a number: ")
if guess > number:
lower(guesses)
elif guess < number:
higher(guesses)
elif guess == number:
correct(guesses)
while True:
answer = input("Would you like to play again? Y or N: ")
if answer == "Y":
break
elif answer == "N":
exit()
else:
exit()
_main_(guesses)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…