major updates to the solutions
[wordplay-cdsw-solutions] / solution_5_advanced.py
index aac8b198da6850e21746b8f634e372d4f6bfb0a9..202648b3506be5a838fd4dae187ccc02ee68218c 100644 (file)
@@ -1,23 +1,23 @@
 import scrabble
 
 
-# This is a solution to 5 that reuses the code in 1. 
-# Whenever we can, it's good to reuse code that we already have.
-# Next Saturday, we'll talk about defining functions, which is the way programmers
+# This is a solution to 5 that reuses the code in 1.  Whenever we can,
+# it's good to reuse code that we already have.  In a future session,
+# we'll talk about defining functions, which is the way programmers
 # re-use code.
 
 matching_words = []
 
-
 for word in scrabble.wordlist:
     if word[0] == 'a' and len(word) >= 9:
         matching_words.append(word)
 
 
-# Note that I use enumerate. You should look that up online to see what it does.
+# Note that I use enumerate. You can look up the enumerate function
+# online to see what it does. We're also using a new operating "%"
+# which is the modulo operator and which is more flexible than the
+# "bool" based version we used before.
+
 for i, word in enumerate(matching_words):
     if i % 2 == 0:
-       print word
-            
-
-
+        print(word)

Benjamin Mako Hill || Want to submit a patch?