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))
Objective is to determine if all the letters of secretWord
are contained in lettersGuessed
.
My code is working. Is there any way Pythonica does?