I am trying to print all the letters in all the words in a list, without duplicates. I tried:
>>> wordlist = ['cat','dog','rabbit']
>>> letterlist = []
>>> [[letterlist.append(x) for x in y] for y in wordlist]
[[None, None, None], [None, None, None], [None, None, None, None, None, None]]
>>> letterlist
['c', 'a', 't', 'd', 'o', 'g', 'r', 'a', 'b', 'b', 'i', 't']
The desired result is ['c', 'a', 't', 'd', 'o', 'g', 'r', 'b', 'i']
instead.
How do I modify the list comprehension to remove duplicates?