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
'''
certas =0
for i in range(len(secretWord)):
if secretWord[i] in lettersGuessed:
certas += 1
#print(certas)
if certas == len(secretWord):
return True
else:
return False
secretWord = 'durian'
#lettersGuessed = ['e', 'i', 'k', 'p', 'r', 's']
#lettersGuessed = ['e', 'a', 'l', 'p', 'e']
#isWordGuessed('durian', ['h', 'a', 'c', 'd', 'i', 'm', 'n', 'r', 't', 'u'])
lettersGuessed = ['h', 'a', 'c', 'd', 'i', 'm', 'n', 'r', 't', 'u']
print(isWordGuessed(secretWord, lettersGuessed))
Objetivo é determinar se todas as letras de secretWord
estão contidas em lettersGuessed
.
O meu código está funcionando. Existe alguma maneira Pythonica de fazer?