Scrabble Word Score Checker: Calculate Points with Ease

Create a Scrabble word score checker by iterating through letters of a given word, looking up each letter's value from a dictionary, and summing these values to calculate the score.

Discover how to build a Scrabble word score checker using Python, looping through individual letters and calculating their values. Enhance your skills by adding interactivity, allowing users to input words dynamically.

Key Insights

  • Explains how to iterate over a string letter by letter, treating each character as part of an iterable collection, and demonstrates this with clear Python examples.
  • Introduces the concept of dictionaries in Python by creating one named "Scrabble letter values," which maps each uppercase letter to its corresponding Scrabble score.
  • Guides readers step-by-step to create an interactive Scrabble score calculator that takes user inputs, converts letters to uppercase, matches them in the dictionary, and calculates a final word score.

Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.

This is a lesson preview only. For the full lesson, purchase the course here.

Scrabble word score checker challenge. If you don't know what Scrabble is, it's a game where you basically play a crossword puzzle on a board. You get dealt some letter tiles, right, as little wood tiles.

And each letter has a point value. The more commonly used letters have lower scores, and letters like X or Z have a higher point value because they don't get used as much. You and your opponents make words on the board using your available letters, trying to intersect crossword-style with existing words. So what we want to do is make a little Scrabble word score checker.

Not really going to be a challenge—we're going to do this together. We'd like to have a word and then figure out its Scrabble score. So to do that, let's declare a word.

We'll say word equals elephant. Now what we want to do is—remember, you can loop. Do we know that yet? Wait, do we even know that?

For letter in word, print letter. I don't think we did. No, we did not do that last time.

Python for Data Science Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

In the last lesson, we got into loops, but you can loop. Think of a string as a little list of letters, and you can iterate letter by letter over the string. You don't have to just iterate over a list.

A string is itself iterable—it can be looped over. Think of a string as a little list of letters.

So here we are iterating the word letter by letter and printing the letters. In so doing, we could look at stuff. Let's print whether each letter is a vowel.

If the letter is a vowel, add "is a vowel" after the letter. How's that? We'll have a little letter. Wait, what are we going to do here? Okay, so we're going to loop letter by letter and we're going to have our vowels—if you recall, that little list of vowels.

And what we want to do as we loop: if the letter is a vowel, we're going to print it with the phrase "is a vowel" after it. We're going to say E is a vowel. L will print without anything after it because L is not a vowel. Then E will print "E is a vowel, " and then P and H will print without anything after, and A will print "is a vowel."

Just trying to get a little practice in accessing and doing stuff on the level of the individual letter. We'll say if letter in vowels, then we're going to print "letter is a vowel." Else, just print the letter. That worked.

We can do stuff as we go through the letters. Well, if we can do that, what else can we do? We could actually look at the individual letters and look them up by key—you know, treat the letters as the key and go look up and return the value of the Scrabble letter score. All right, so we're going to look up the Scrabble value of each letter as we loop.

Let's actually do that as a separate box. Keep a running score to calculate the Scrabble score of the word. So our word is elephant.

We can just write that again for reference. And we have our vowels—let's just put that again for reference.

Oh, we don't need the vowels. It's not about the vowels. We've got our Scrabble letter values.

That's what it's about—Scrabble letter values. I'm going to change that to Scrabble letter values.

No, it's not really a Scrabble dictionary. The Scrabble Dictionary is an actual list of around 180,000 legally playable words.

Let's just call it Scrabble. Let's call it Scrabble letter values.

Let’s leave it as is—Scrabble letter values. It's long, but it expresses what it is.

Okay, so we're going to loop. We're going to say "for letter in word." And we're going to start with a score of zero, right? We're going to say print Scrabble letter values, and we're going to pass in the letter.

But the letters of our word are lowercase. The keys in Scrabble letter values are uppercase. We’ll want to convert the letter to uppercase.

Let's just print. And it doesn't like it. Scrabble letter values is not defined.

Oh, I haven't run this. Okay, let's run that. Run.

There. It's printing. It's going through "elephant" letter by letter and printing the value every time.

Great. In that case, we can store that. We can say "letter value = Scrabble letter values[letter.upper()]."

And we'll say "score += letter value." And we’re all done. We'll print the word.

Just print the word. And we'll just print the score. There it is.

That's the Scrabble score of the word. Yep.

And we could even—there. Or use your f-string formatting: wrap the word in single quotes and then double quotes around the output. There we go.

If we can do that, why can we not also let the user input a word and then we grab whatever word they typed in? We haven't done an input in a while. That was in lesson one, I think. Well, that’s when we first learned about it anyway.

So rather than have a hardcoded "elephant, " we're going to let you type your word and then use it that way. You grab the user’s input and assign it to the variable word. So actually, let's just take all this and make an input.

The only change is to replace the hardcoded word with an input from the user—just let the user or player enter a word. So the big change would be: "Enter word to get Scrabble score." So that would be input("Enter a word: ").

Then your score is reset to zero, and you just loop it like we did. We'll say "kumquat" – 22, "rutabaga" – 11, "persimmons" – 16. Okay, you get the idea.

"Artichoke" – 18. We have a little Scrabble word score calculator. This next section is more of an advanced challenge.

I don't know if we want to even do it, but let's just back up a second. You've got a dictionary of key-value pairs—every letter and its Scrabble value. Then we've looked at how you can iterate over a string letter by letter and then do stuff.

In this case, we're checking to see if the current letter is a vowel and if so, noting that as we print each letter. Now that we've seen that we can access individual letters in a loop, we'll take the individual letter, uppercase it, and look it up in the Scrabble values—right? Like so. Just put all that together. So here's your Scrabble values.

So long. That's a few lines. Okay, so we have our Scrabble letter values—a dictionary of key-value pairs.

We have our word. And then we're going to loop through the word letter by letter. We're going to take the letter, uppercase it—like E in "elephant"—and use that.

Look up that key and retrieve its value, and then save the value and increment the score by it. You could save a step by simply directly incrementing, because Scrabble letter values['E'] returns a number, and you just add the number—but doing it in two steps makes it easier to read. And then, coming down to the next thing, it's the same exact move, except now you are allowing the user to enter the word with an input, making it a little more interactive and dynamic.

Okay, get out of here. Why are you here? Scrabble letter values: dictionary of every letter (uppercase) with a value associated with it, an input where you type in a word, score reset to zero, loop through the word letter by letter, take each letter, uppercase it to match the keys, go to the dictionary using that key to fetch the value, and then increment the score to accumulate a total—then just print the answer. And that’s our introduction to dictionaries.

Brian McClain

Brian is an experienced instructor, curriculum developer, and professional web developer, who in recent years has served as Director for a coding bootcamp in New York. Brian joined Noble Desktop in 2022 and is a lead instructor for HTML & CSS, JavaScript, and Python for Data Science. He also developed Noble's cutting-edge Python for AI course. Prior to that, he taught Python Data Science and Machine Learning as an Adjunct Professor of Computer Science at Westchester County College.

More articles by Brian McClain

How to Learn Python

Master Python with hands-on training. Python is a popular object-oriented programming language used for data science, machine learning, and web development. 

Yelp Facebook LinkedIn YouTube Twitter Instagram