I am trying to write a function, that returns a string letters that are not in lettersGuessed
words = list('abcdefghijklmnopqrstuvwxyz')
def getAvailableLetters(lettersGuessed):
[words.remove(letter) for letter in words if letter in lettersGuessed]
return ''.join([str(elem) for elem in words])
then i call my function
getAvailableLetters(['e', 's', 'i', 'k', 'p', 'r'])
But the result is different from what I expected. My output:
'abcdfghjlmnoqstuvwxyz'
# the letter 's' in the output, but it shouldn't be there.
Correct output:
'abcdfghjlmnoqtuvwxyz'
what am I doing wrong ?
Aucun commentaire:
Enregistrer un commentaire