我在学习python时遇到了这个问题,我试图过滤是否大于n小于x的数字
在其他线程中,我读到您可以执行以下操作:
如果10
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))
答案 0 :(得分:1)
您的elif语句不以:
结尾!
答案 1 :(得分:0)
您错过了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))