编辑: 所以只是一个简单的问题 所以这很好,但是我关心的是如果他们输入YES并且是的?
import sys
import random
roll_again = "yes"
msg=input('Dice Rolling Simulator. Let the dices be ever in your favour. Press ENTER to start our game of luck')
if msg!=input:
pass
while roll_again == "yes":
min = 1
max = 6
face = random.randint (min,max)
print (face)
cmd=input("Would you like to roll the dice again? Type yes if you do.")
if cmd != roll_again : #if it is not 'yes' then system automatically exits.
print ("One who doesn't throw the dice can never expect to score a six. -Navjot Singh Sidhu")
sys.exit()
对不起,我很不确定,可能有点累了以前的所有打火机。 请帮忙
答案 0 :(得分:0)
import random
roll_again = "yes"
msg = input('Dice Rolling Simulator. Let the dices be ever in your favour. Press ENTER to start our game of luck\n')
# While the input in lower case is equal to "yes" a dice will be rolled
while msg.lower() == "yes":
min = 1
max = 6
face = random.randint (min,max)
print (face)
msg = input("Would you like to roll the dice again? Type yes if you do.\n")
# we get here when the input in lower case is not equal to "yes
print("One who doesn't throw the dice can never expect to score a six. -Navjot Singh Sidhu")
# no need of sys.exit() because system will exit anyway
答案 1 :(得分:0)
我认为这可以做你想做的事情:
{}
再次滚动的输入应该在while循环中,因为你现在已经进入了一个无限循环并且永远不会到达第二个输入查询。