我正在尝试创建一个简单的python记分板。最后,我将添加按钮来增加和减少值。这是我当前的代码,我如何让它打印“新游戏”并在有人获胜后5秒重新启动循环?在
RedScore = 0
BlueScore = 0
while RedScore <= 5 and BlueScore <= 5:
if RedScore == 5:
print('RED WINS')
break
elif BlueScore == 5:
print('BLUE WINS')
break
else:
x = input("Who Scored? ")
if x == 'Red':
RedScore += 1
print(RedScore)
elif x == 'Blue':
BlueScore += 1
print(BlueScore)
else:
print('Bad Input')
另外,我想添加一个条件,如果你输入“REDRESET”,RED的分数将=3
如果您只想让它等待5秒,那么在循环运行后
sleep
5秒钟。添加REDRESET
与拥有另一个elif
一样简单相关问题 更多 >
编程相关推荐