added new python programs with solutions for the ideas listed on the wordplay page
[wordplay-cdsw-solutions] / idea_3.py
diff --git a/idea_3.py b/idea_3.py
new file mode 100644 (file)
index 0000000..46c6aec
--- /dev/null
+++ b/idea_3.py
@@ -0,0 +1,27 @@
+# 3. Find and print the longest word that has no vowels.
+
+import scrabble
+
+vowels = ['a', 'e', 'i', 'o', 'u']
+words_without_vowels = []
+
+for word in scrabble.wordlist:
+    vowel_in_word = False
+    for vowel in vowels:
+        if vowel in word:
+            vowel_in_word = True
+    if not vowel_in_word:
+        words_without_vowels.append(word)
+
+longest_word_length = 0
+longest_words = []
+for word in words_without_vowels:
+    if len(word) > longest_word_length:
+        longest_words = [word]
+        longest_word_length = len(word)
+    elif len(word) == longest_word_length:
+        longest_words.append(word)
+
+for word in longest_words:
+    print(word)
+

Benjamin Mako Hill || Want to submit a patch?