Python,整数处理为字符串。

时间:2015-07-23 23:42:47

标签: python string types integer

初学者在这里学习python。我在处理以下代码时遇到问题。我正在尝试比较数字,但我得到一个“无法解决的类型错误”。我不明白为什么,因为两个被比较的数字都是整数。

winning_number = 5

guess = input("Can you guess the lucky number.\nHint it's between 1 and 10!\n")

def compare(guess):
    if guess > winning_number:
        print ("Wrong, you're guess is too high")
    elif guess < winning_number:
        print ("Wrong, you're guess is too low")
    else:
        pass

compare(guess)

0 个答案:

没有答案