这是我的准则
running = True
while running:
print("Open Supply Drop?.")
answer = input()
if answer == ("Yes"):
print("Please wait 3 seconds...")
import time
time.sleep(3)
import random
callingcard = ['BootsOnTheGround', 'TitanBaseCamp', 'TitanFacility', 'TitanicStorm', 'TitanicCanyon', 'TitanSandstorm', 'ToTheShip', 'AsteroidMines', 'TheSteelDragon', 'C6Assembly', 'C12Patrol']
print("You got...")
print(random.choice(callingcard)
elif answer == ("yes"):
print("Please wait 3 seconds...")
import time
time.sleep(3)
import random
callingcard = ['BootsOnTheGround', 'TitanBaseCamp', 'TitanFacility', 'TitanicStorm', 'TitanicCanyon', 'TitanSandstorm', 'ToTheShip', 'AsteroidMines', 'TheSteelDragon', 'C6Assembly', 'C12Patrol']
print("You got...")
print(random.choice(callingcard))
else:
print("Please wait 3 seconds...")
import time`enter code here`
time.sleep(3)
如果,elif和else有语法错误?我只改变了一些东西,而且完美地工作了,但是现在不管怎样,它都是这样的,是不是和缩进有关?在
如前所述,您在一行中缺少一个paren。你有几个问题,所以我写了一个干净的版本
callingcard
列表已从循环中拉出。它被重写为一个不可变的元组(列表暗示您计划修改)和 添加新行以保留行数<;80个字符break
代替while
中的哨兵值Yes
和yes
而重复的这个例子
你的缩进不一致。Python完全基于缩进语法,您需要将IF、ELIF和ELSE选项卡下的所有行设置为相同的数量。 此外,由于设置running=True,但从未将其设置为任何其他值,因此从while开始将有一个无限循环。希望有帮助。在
以下是您代码的临时版本: 我也在猜测IF,ELSE应该在while循环下缩进??在
^{pr2}$相关问题 更多 >
编程相关推荐