reworked these examples a bit based on feedback in class
[wordplay-cdsw-solutions] / solution_2.py
index 9d5469d8cbbc5a93f2c0e221cd2214390a545f8b..f6deda9bac1e55145e18ba4334c80f8e7dc8d5bc 100644 (file)
@@ -1,21 +1,15 @@
 import scrabble
 
 import scrabble
 
-
 # What is the longest word that starts with a q?
 # What is the longest word that starts with a q?
+
 # This is the most common student solution, which prints the *first* occurence of
 # the longest word. See solution_2_advanced.py for more info.
 
 longest_so_far = '' # Store the longest word we've seen up to this point.
 
 for word in scrabble.wordlist:
 # This is the most common student solution, which prints the *first* occurence of
 # the longest word. See solution_2_advanced.py for more info.
 
 longest_so_far = '' # Store the longest word we've seen up to this point.
 
 for word in scrabble.wordlist:
-
     if word[0] == 'q':
     if word[0] == 'q':
-       if len(word) > len(longest_so_far):  # What if I use >= rather than > here?
-           longest_so_far = word
-            #print word  # Use this to see the progression.
-
-
-print longest_so_far
-            
-
+        if len(word) > len(longest_so_far): # Question: What if I use >= rather than > here?
+            longest_so_far = word
 
 
+print(longest_so_far)

Benjamin Mako Hill || Want to submit a patch?