Real Python: Build a Wordle Clone With Python and Rich :

Real Python: Build a Wordle Clone With Python and Rich
blow post content copied from  Planet Python
click here to view original post

In this tutorial, you’ll build your own Wordle clone for the terminal. Since Josh Wardle launched Wordle in October 2021, millions of people have played it. While you can play the original game on the Web, you’ll create your version as a command-line application and then use the Rich library to make it look good.

As you follow along in this step-by-step project, you’ll practice how to set up a simple prototype game before iteratively developing it into a solid application.

In this tutorial, you’ll learn how to:

  • Build out a command-line application from a prototype to a polished game
  • Read and validate user input
  • Use Rich’s console to create an attractive user interface in the terminal
  • Organize your code into functions
  • Provide your users with actionable feedback

You’ll create Wyrdl, your own Wordle clone in Python. This project is for anyone getting comfortable with Python who wants to build a terminal application from the ground up. Throughout the tutorial, you’ll build your code step-by-step while focusing on having a game that you can play from the start. You can download all the code by clicking below:

Free Source Code: Click here to download the free source code that you’ll use to build a Wordle clone with Python and Rich.

Read on to see what you’ll be building.

Demo: Your Python Wordle Clone

In Wordle, you have six attempts to guess a secret five-letter word. After each guess, you’ll get feedback about which letters are correctly placed, which are misplaced, and which are wrong.

The New York Times bought the original Wordle in early 2022, and you can now play the game on their website. The game has a social aspect that you won’t re-create in this project. There’s one secret word per day, and all players are guessing the same word.

Your version of the game will look like the following:

After you make a guess, each letter is categorized. Correct letters are marked in green, misplaced letters are marked in yellow, and wrong letters are marked in gray.

If you make any mistakes, like guessing a word with six letters, then the game will give you appropriate feedback and let you take another guess.

Project Overview

An important part of this project is bootstrapping the application early. You want to have code that runs so that you can test that your code works, and you can experiment with different ways of implementing the features that you need in your game.

You’ll build your Wordle clone iteratively, going through the following steps:

  1. Create a simple prototype that allows you to guess a secret word and gives you feedback on the individual letters.

  2. Make the game more interesting by including a list of words that the game randomly chooses from.

  3. Refactor the code to use functions.

  4. Add color and style to the game using the Rich library.

  5. Provide actionable feedback to your users when they play the game.

  6. Improve the user interface by adding the status of all the letters in the alphabet.

As you work through the tutorial, you’ll see how you can start with a small idea and grow it into a full-featured application. After all, that was Wordle’s journey!


In this tutorial, you’ll build a Wordle clone using Python and Rich. While working through the steps, it’s helpful if you’re comfortable with the following concepts:

If you’re not confident in your knowledge of these prerequisites, then that’s okay too! In fact, going through this tutorial will help you practice these concepts. You can always stop and review the resources linked above if you get stuck.

It’s time to dive in!

Step 1: Guess a Word

Read the full article at »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

February 06, 2023 at 07:30PM
Click here for more details...

The original post is available in Planet Python by
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.