python学习-TypeError: ‘<=’ not supported between instances of ‘str’ and 'int’问题
今天学习python遇到TypeError: ‘<=’ not supported between instances of ‘str’ and 'int问题
报错原因是:input()输入的内容是一个字符串,字符串跟整型数值进行比较,类型不匹配
修改方法:
i = int(input())
把其转化为整形就?辽
print("-----猜数字游戏-----")
print("请输入1-10之间的任意一个数")
i=int(input())
print(i)
if i<=9:
print("太小,请重新输入")
else :print("恭喜你,你赢了,猜中的数字是:"+str(i))