I have a list word_list = ['cat', 'dog', 'rabbit']
.
I want to use list comprehension to print each individual character from the list but removes any duplicate character. This is my code:
word_list = ['cat', 'dog', 'rabbit']
letter_list = [""]
letter_list = [letter for word in word_list for letter in word if letter not in letter_list ]
print(letter_list)
this returns ['c', 'a', 't', 'd', 'o', 'g', 'r', 'a', 'b', 'b', 'i', 't']
which is not the desired result ['c', 'a', 't', 'd', 'o', 'g', 'r', 'b', 'i']
and I can't figure out why.