編輯: 所以這只是一個快速的問題 所以這是偉大的,所有,但我的關注是如果他們鍵入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()
對不起,我很不確定,可能從以前的所有夜晚都有點累。 請幫助
continue語句用於跳過循環的其餘部分。你能提供更多的例子嗎? – gonczor
沒有多個'if's。只需將輸入的字符串轉換爲小寫,並將其與「是」進行比較即可。你應該顯示完整的循環,很難從不完整的代碼中判斷你的錯誤。 –