Whitespace corrections, a couple bug fixes, replacing a format string with constructi...
[wordplay-cdsw-solutions] / solution_2.py
1 import scrabble
2
3 # What is the longest word that starts with a q?
4 # This is the most common student solution, which prints the *first* occurence of
5 # the longest word. See solution_2_advanced.py for more info.
6
7 longest_so_far = '' # Store the longest word we've seen up to this point.
8
9 for word in scrabble.wordlist:
10
11     if word[0] == 'q':
12         if len(word) > len(longest_so_far): # What if I use >= rather than > here?
13             longest_so_far = word
14             #print word # Use this to see the progression.
15
16 print longest_so_far

Benjamin Mako Hill || Want to submit a patch?