Scrabble challenge: Difference between revisions

no edit summary
imported>Jesstess
imported>Jesstess
No edit summary
Line 69:
====Step 2: get the rack====
 
Write the code to get the Scrabble rack (the letters available to make words) from the command line argument passed to your script. For example if your script were called `scrabble_cheater.py`, if you ran `<tt>python scrabble_cheater.py RSTLNEI`</tt>, `<tt>RSTLNEI`</tt> would be the rack.
 
Handle the case where a user forgets to supply a rack; in this case, print an error message saying they need to supply some letters. Make sure you are consistent about capitalization: if your scores dictionary is lowercase, the letters supplied by the user need to be converted to lowercase at some point before you compare them.
Line 87:
====Step 3: find valid words====
 
Write the code to find all words from the word list that are made of letters that are a subset of the rack letters. There are many ways to do this, but here's one way that is easy to reason about and is fast enough for our purposes: go through every word in the word list, and for every letter in that word, see if that letter is contained in the rack. If it is, save the word in a <tt>valid_words</tt> list. Make sure you handle repeat letters: once a letter from the rack has been used, it can't be used again.
 
<b>Step 3 resources</b>:
Line 93:
<li>
List manipulation: http://docs.python.org/tutorial/datastructures.html#more-on-lists.
</li>
<li>
<tt>for</tt> loops: http://docs.python.org/tutorial/controlflow.html#for-statements
</li>
</ul>
Line 107 ⟶ 110:
</li>
</ul>
 
 
===Checking your work===
Line 143 ⟶ 147:
===Congratulations!===
 
You've implemented a substantial, useful script in Python from scratch that is perfect for cheating at Scrabble or Words with Friends. Keep practicing!
Anonymous user