|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
print("hellow,guys")
temp = input("please input" )
test = range(1,5)
women = int(temp)
while women != range(1,5):
print("sorry,error")
temp = input("again")
women = int(temp)
if women in range(1,5):
print("good")
请问一下,为什么我即使输入1到5的数字,返回的还是error?还有请问一下,python如果要编辑的条件是“不在某个范围中(例如1到5)”,应该怎么写呢?
改成这样:
- print("hellow,guys")
- temp = input("please input" )
- test = range(1,5)
- women = int(temp)
- while women not in test:
- print("sorry,error")
- temp = input("again")
- women = int(temp)
- print("good")
复制代码
整数不能直接和range类型比较的
|
|