def isWordGuessed(secretWord, lettersGuessed):
'''
secretWord: string, the word the user is guessing
lettersGuessed: list, what letters have been guessed so far
returns: boolean, True if all the letters of secretWord are in lettersGuessed;
False otherwise
'''
score = 0
tot = len(secretWord)
for i in range(len(secretWord)):
for j in range(len(lettersGuessed)):
if (secretWord[i] == lettersGuessed[j]):
score +=1
if score == tot:
return True
else:
return False
对于大多数单词和猜测字母 m 得到正确答案,但同时提供 sceretWord asmangosteen
和字母猜测,因为 ['z', 'x', 'q', 'm', 'a', 'n', 'g', 'o', 's', 't', 'e', 'e', 'n']
我得到错误的输出。
有什么建议,为什么?