我希望標題足夠說明了。基本上,用戶輸入一個數字,數字必須在1到147之間。如果是,則達到下一個必需的輸入(num_guess)。但是如果數字不在參數範圍內,我們需要讓用戶再次嘗試。但我無法弄清楚如何做到這一點。提前致謝。如果返回else語句,如何返回到循環的頂部
word_correct = False
def length_check(x):
while (word_correct == False):
if x >= 1 and x <= 147:
return word_correct == True
break
else:
print("Try another number")
# print(input("Please enter a word length: ")) ## ignore me
word_length = input("Please enter a word length: ")
length_check(word_length)
num_guess = raw_input("Please enter an amount of guesses: ")
這沒有意義....你究竟在做什麼? –