python的input输入的是str类型的,要想实现逻辑运算必须转化为int类型。
例如:
A=input('输入1至100的数字')
if A>=1 and A<=100:
print('well done')
else:
print('wrong')
会报错: '>=' not supported between instances of 'str' and 'int',应当修改为:
A=int(input('输入1至100的数字'))
if A>=1 and A<=100:
print('well done')
else:
print('wrong')