n = input("What is your number")
if n > 0:
print("It's Bigger Than 0")
else:
print("It's smaller than 0")
为什么会出错 TypeError:'>' 'str'和'int'实例之间不支持
答案 0 :(得分:-1)
将第一行更改为:
n = int(input("What is your number"))
在Python 3中,input
总是返回一个字符串。
答案 1 :(得分:-1)
input()
函数返回一个字符串。因此,在将代码分配给int
n
n = int(input("What is your number"))
if n > 0:
print("It's Bigger Than 0")
else:
print("It's smaller than 0")