-1
我面臨的問題是如何檢測我的Hang子手遊戲中的重複輸入。請幫幫我! 這裏是我的代碼:(。首先,我呼籲遊戲的功能和我同時使用循環) 高清checkValidGuess():如何檢測我的hang子手遊戲(Python)中的重複輸入!
if guessword in guess:
print("Repeat")
elif guessword in num:
print("You can only input letter a-z")
print("Try again")
elif len(guessword) >1:
print("You can only guess one letter at a time!")
print("Try again")
def checkPlayerWord():
if guessall == word:
print("Well done")
else:
print("Uh oh!")
def checkLetterInWords():
if guessword.lower() in word:
print("Well done!",guessword,"is in my word")
elif guessword.lower() not in word and guessword.lower() not in num:
print("Try again")
choose = input("Enter your choice:")
readFileWords()
time =10
word = getRandomWord()
while time !=0 and word:
print("You have", time, "guesses left.")
guessword = input("Guess a letter or enter '0''to guess the word:")#This is user input to guess the letter
num = ["1","2","3","4","5","6","7","8","9"]
guess=[]
checkValidGuess()
if guessword =="0":
guessall = input("What is the word: ")
checkPlayerWord()
else:
checkLetterInWords()
您能添加更多關於代碼的信息嗎? – Jeril
@Jeril ok!我剛剛編輯。謝謝!它的工作原理是 – VincentHoang