Skillshare intro to Python/Unit 5: Difference between revisions
Content added Content deleted
imported>Jesstess |
imported>Jesstess |
||
Line 123: | Line 123: | ||
Once we have a list of valid words, we need to get the Scrabble scores for each word. |
Once we have a list of valid words, we need to get the Scrabble scores for each word. |
||
To do this, use a <code>for</code> loop to go through each word in <code>valid_words</code>. For each word, use a counter to keep track of the score so far for the word. Then use another <code>for</code> loop to go through the word letter by letter; look up each letter in the <code>scores</code> dictionary and |
To do this, use a <code>for</code> loop to go through each word in <code>valid_words</code>. For each word, use a counter to keep track of the score so far for the word. Then use another <code>for</code> loop to go through the word letter by letter; look up each letter in the <code>scores</code> dictionary and add the point value for that letter to the counter. |
||
To check your work, use the <code>print</code> function to print each word in <code>valid_words</code> and its Scrabble value. |
To check your work, use the <code>print</code> function to print each word in <code>valid_words</code> and its Scrabble value. |