"Python Dictionary Explained: The Ultimate Guide
"2026-11-10
If you are learning to code, you will quickly encounter the python dictionary. A dictionary is one of the most powerful data structures in the language. It allows you to store data in key-value pairs, which makes it easy to look up information instantly.
In this tutorial, we will look at how a python dictionary works, and we will use it to change colors and draw shapes with Python Turtle.
What is a Python Dictionary?
A dictionary is a collection of items. Each item has a "key" and a "value". Think of it like a real dictionary: the word is the key, and the definition is the value.
You create a dictionary using curly braces {}. Inside, you separate keys and values with a colon :.
Using a Dictionary with Turtle
You can use a dictionary to store the pen color and background color for your turtle graphics. This makes your code clean and easy to change.
See What You Can Build
Once you master dictionaries, you can create stunning visual art. Check out this Mandala, which uses color palettes to create a symmetrical design.

This design uses color data and loops to create a beautiful floral effect.
View the Full Code
Start Learning Data Structures
Dictionaries are a core concept in Python. To understand how they work with loops, take our interactive lesson on variables and loops.
Take Python Everywhere
If you want to practice Python Turtle and master Python on your phone, we highly recommend Python Play. It features a built-in Turtle graphics playground and 100 interactive levels to test your coding skills.
Python Play: Coding & Quiz App
Learn Python, solve 100 challenges, and run real Turtle graphics code directly on your phone. No setup required.
Get it on Google Play