I'm learning list comprehensions in Python. I was to append letters from a list of words and form a new list but without duplicates. This is what I'm trying:
wordlist = ['cat','dog','rabbit']
letterlist = [aletter for aword in wordlist for aletter in aword if aletter not in letterlist]
print letterlist
I'm getting the following error:
Traceback (most recent call last):
File "training.py", line 5, in <module>
letterlist = [aletter for aword in wordlist for aletter in aword if aletter not in letterlist]
NameError: name 'letterlist' is not defined
What am I doing wrong ?