X-Git-Url: https://projects.mako.cc/source/wordplay-cdsw-solutions/blobdiff_plain/884ad8e21ea1ea9d1dd411b2a503d0dff4294c59..HEAD:/solution_5_advanced.py diff --git a/solution_5_advanced.py b/solution_5_advanced.py index aac8b19..202648b 100644 --- a/solution_5_advanced.py +++ b/solution_5_advanced.py @@ -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)