[英]greater than but less than function in python usage
while I was studding python I run into this problem that I'm trying to filter if a number is bigger than n and smaller than x in other thread I read that you could just do this: if 10 < a < 20: whatever but when I run the code Im getting invalid syntax 我在学习python时遇到了这个问题,我试图过滤其他线程中是否大于n且小于x的数字,但我读到您可以这样做:if 10 <a <20:what when我运行代码Im语法无效
while guess != rightnum:
guess=int(input('your guess: '))
diff= abs(guess - rightnum)
if guess > rightnum and diff >= 1000 :
print(random.choice(muchless))
elif guess > rightnum and 1000 > diff >= 100
print(random.choice(less))
elif guess > rightnum and diff < 100
print(random.choice(fewless))
您的elif语句不以:
结尾
You missed 2 colons 您错过了2个冒号
while guess != rightnum:
guess=int(input('your guess: '))
diff= abs(guess - rightnum)
if guess > rightnum and diff >= 1000 :
print(random.choice(muchless))
elif guess > rightnum and 1000 > diff >= 100 :
print(random.choice(less))
elif guess > rightnum and diff < 100 :
print(random.choice(fewless))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.