Program Jumbled Game in Python
In this tutorial, you will learn Python Lists basics. This will enable you to create a Jumbled Game.
Step 1: Python Lists and Indexing
A Python list is like a list you know it. And the beauty of Python lists is that they can contain anything.
But let’s get started immediately. You can define a list as follows. This list contains strings, but it could contain any type or object.
my_list = ['Apple', 'Orange', 'Banana']
You get the length of a list by using len().
len(my_list)
Which will return 3.
A list is indexed from 0 – that is you get the first element as follows.
my_list[0]
The second element.
my_list[1]
And it continues as you can guess.
You can index from the end of a list by negative indexing – the last element is indexed by -1.
my_list[-1]
Then the second last element with.
my_list[-2]
Step 2: Get a random element from a list.
Remember the random library we used?
Well, it can be applied to a list.
import random
my_list = ['Apple', 'Orange', 'Banana']
random_item = random.choice(my_list)
print(random_item)
This will pick a random item from the list.
Step 3: Pick random samples from a sequence like a string
Imagine you want to get random samples from a sequence.
What is a sequence, well it can be a string? A string in Python is a sequence.
Then you can pick random samples from it.
letter_sequence = 'abcdefgh'
samples = random.sample(letter_sequence, len(letter_sequence))
Then samples will be a list of unique elements from letter_sequence. Hence, it is all the letters uniquely represented.
Step 4: The Jumbled Game Explained
The jumbled game can be described as follows.
- A word jumble is a word puzzle game that presents the player with a bunch of mixed-up letters and requires them to unscramble the letters to find the hidden word.
- The computer will take a word and jumble it (mix up the letters).
- Then the player will guess what the word is
- An initial word list could be: [‘father’, ‘enterprise’, ‘science’, ‘programming’, ‘resistance’, ‘fiction’, ‘condition’, ‘reverse’, ‘computer’, ‘python’]
Step 5: Implement the Jumbled Game
This is straightforward with our competencies.
import random
words = ['father', 'enterprise', 'science', 'programming', 'resistance', 'fiction', 'condition', 'reverse', 'computer', 'python']
word = random.choice(words)
jumble = random.sample(word, len(word))
jumble = ''.join(jumble)
print(f"The jumble word is: {jumble}")
guess = input(f"Write your guess: ")
if guess.lower() == word:
print(f"Corret! The {jumble} is {guess}")
else:
print(f"Incorrect! The {jumble} is {word}")
Want more?
I am happy you asked.
If this is something you like and you want to get started with Python, then this is part of an 8 hours FREE video course with full explanations, projects on each level, and guided solutions.
The course is structured with the following resources to improve your learning experience.
- 17 video lessons teaching you everything you need to know to get started with Python.
- 34 Jupyter Notebooks with lesson code and projects.
- 2 FREE eBooks to support your Python learning.
See the full FREE course page here.
Learn Python

Learn Python A BEGINNERS GUIDE TO PYTHON
- 70 pages to get you started on your journey to master Python.
- How to install your setup with Anaconda.
- Written description and introduction to all concepts.
- Jupyter Notebooks prepared for 17 projects.
Python 101: A CRASH COURSE
- How to get started with this 8 hours Python 101: A CRASH COURSE.
- Best practices for learning Python.
- How to download the material to follow along and create projects.
- A chapter for each lesson with a description, code snippets for easy reference, and links to a lesson video.
Expert Data Science Blueprint

Expert Data Science Blueprint
- Master the Data Science Workflow for actionable data insights.
- How to download the material to follow along and create projects.
- A chapter to each lesson with a Description, Learning Objective, and link to the lesson video.
Machine Learning

Machine Learning – The Simple Path to Mastery
- How to get started with Machine Learning.
- How to download the material to follow along and make the projects.
- One chapter for each lesson with a Description, Learning Objectives, and link to the lesson video.