我一直试图永远修复这段代码,但是我没有成功,我试图在你回答之后做到这一点。它将自动重启程序,您可以再次播放。但是,经过多次尝试后我无法做到这一点
question = input("Press 'r' for rock, 'p' for paper or 's' for scissors")
if question is 'r':
print('I choose paper, I win!')
elif question is 's':
print('I choose rock, I win!')
elif question is 'p':
print('I choose scissors, I win!')
for restart in question:
print(restart)
答案 0 :(得分:1)
试试这个:
while (True):
question = input("Press 'r' for rock, 'p' for paper or 's' for scissors or press 'e' to exit:")
if question is 'r':
print('I choose paper, I win!')
elif question is 's':
print('I choose rock, I win!')
elif question is 'p':
print('I choose scissors, I win!')
elif question is 'e':
print('restart')
break
答案 1 :(得分:0)
试试这段代码:
def restart():
question = input("Press 'r' for rock, 'p' for paper or 's' for scissors")
if question is 'r':
print('I choose rock, I win!')
elif question is 's':
print('I choose scissors, I win!')
elif question is 'p':
print('I choose papers, I win!')
else:
print('wrong choice')
continuePlay = 'y'
while continuePlay is 'y':
restart()
continuePlay = input("Press 'y' for Yes, 'n' for No")
答案 2 :(得分:0)
您可以使用功能。
model.fit()
答案 3 :(得分:-1)
您应该在循环中插入input
语句
question = ""
while(question != 'e'):
question = input("Press e to exit")
if question is 'r':
print("....r")
elif question is 's':
print(".....s")`