Python 滥用continue循环,根据大写和小写答案比较输入

Python 滥用continue循环,根据大写和小写答案比较输入,python,python-3.5,Python,Python 3.5,编辑: 所以我只想问一个简单的问题 这很好,但我关心的是,如果他们输入YES和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和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()
对不起,我很不确定,可能因为前一个通宵而有点累。
请帮助

我想这正是您想要它做的:

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
import sys
import random

roll_again = "yes"

input("Dice Rolling Simulator. Let the dices be ever in your favour. Press ENTER to start our game of luck")

while True:
    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.lower() != 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()

再次滚动的输入应该在while循环中,因为您现在已经进入无限循环,并且永远不会到达第二个输入查询。

continue station用于跳过循环的其余部分。您能提供uller示例吗?如果s,则没有多个
if。只需将输入的字符串转换为小写,并将其与“是”进行比较。您应该显示完整的循环。很难从不完整的代码中判断错误。您好。我试着运行代码,一按enter键,它就立即转到引号:0我觉得它工作得很好。不要直接按回车键,先写“是”,然后按回车键。按enter键会导致
msg=”“
。我明白了。我理解