4 # Print the longest word where every digit is unique.
5 # I used a Set for this. Don't worry: you didn't miss anything if you don't know
6 # what a set is. We didn't teach it, but if you are reading this, you get a bonus!
9 # A set is a container like a list or a dict, except that *each element can be stored only once*.
10 # Think of it like the keys of a dict, except there isn't any value associated with each key.
11 # I use Sets to count digits below. Feel free to look up the Set online and try it in the
16 for word in scrabble.wordlist:
18 if len(word) == len(set(word)): # Wait what!? See if you can figure out why this works.
19 new_words.append(word)
22 # Reuse my code for longest (in this case, the code to track all occurences, from the
26 length_of_longest_word = 0
28 for word in new_words:
29 if len(word) > length_of_longest_word:
30 length_of_longest_word = len(word)
31 longest_so_far = [word]
32 elif len(word) == length_of_longest_word:
33 longest_so_far.append(word)