projects
/
wordplay-cdsw-solutions
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reworked these examples a bit based on feedback in class
[wordplay-cdsw-solutions]
/
solution_7.py
diff --git
a/solution_7.py
b/solution_7.py
index b7f8dde6d7858d1e58d4c0782f067d0c031d0f05..7b89fa399ba88ed91a4ff5f471585c776d26f629 100644
(file)
--- a/
solution_7.py
+++ b/
solution_7.py
@@
-1,20
+1,16
@@
import scrabble
import scrabble
-
-# Find the most valuable word in the dictionary using a double-loop.
-
+# Find the most valuable word in the dictionary using a double-loop.
max_score = 0
max_word = ''
max_score = 0
max_word = ''
+
for word in scrabble.wordlist:
score = 0
for char in word:
score = score + scrabble.scores[char]
if score > max_score:
for word in scrabble.wordlist:
score = 0
for char in word:
score = score + scrabble.scores[char]
if score > max_score:
- max_word = word
- max_score = score
-
-print max_score
-print max_word
-
+ max_word = word
+ max_score = score
+print(str(max_score) + " : " + max_word)
Benjamin Mako Hill
||
Want to submit a patch?