[英]I want to make a code that says something when a number is equal to something, but when it is bigger than or less than that number do something else
This code started out as a joke, but has become something a little more… I am trying to make this code, but I cannot figure out how to make the code for Pluto print when the number they put in is '9'.这段代码一开始只是个玩笑,但后来变得有点……我正在尝试制作这段代码,但是当他们输入的数字是“9”时,我不知道如何让 Pluto 打印代码。 But the only thing I can get is the code for the if statements… when I want it to print the elif statement… If anyone knows the fix for this, let me know!
但我唯一能得到的是 if 语句的代码……当我希望它打印 elif 语句时……如果有人知道解决这个问题的方法,请告诉我!
while True:
amnt = input('Okay, how many planets are in this solar sytem? ')
help = int(amnt)
ast = int(amnt) * 89990189
howMany = print('That means there are roughly ' + str(ast) + ' asteroids in this solar system!')
if help >= 8:
howMany
break
if help <= 100000:
howMany
break
elif help == 9:
print('Um, Pluto isn\'t a planet, you know...')
howMany
break
else:
print('Please try again.')
This is the solution I have found, for your pluto planet:这是我为您的冥王星找到的解决方案:
while True:
amnt = input('Okay, how many planets are in this solar sytem? ')
help = int(amnt)
ast = int(amnt) * 89990189
howMany = print('That means there are roughly ' + str(ast) + ' asteroids in this solar system!')
if help >= 8:
howMany
if help == 9:
print('Um, Pluto isn\'t a planet, you know...')
break
break
if help < 100000:
howMany
break
else:
print('Please try again.')
You have already checked for planets above or equal to 8 so that condition is True and in that you will again check that value (amount) is equal to 9 or not in the same loop.您已经检查了大于或等于 8 的行星,因此条件为 True,并且您将在同一循环中再次检查值(数量)是否等于 9。 It is called nested loop.
它被称为嵌套循环。 I have used it.
我已经用过了。 check it out.
一探究竟。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.