Python Day #11: The Simple Guide to Python Lists and Tuples That Every Beginner Needs
Learn Python lists and tuples with real-world examples in this beginner-friendly guide. Master the basics of data structures and start writing better Python code today.
You’ve been learning all about building a solid foundation with Python. You got this and it all seems so exciting!
You know all about variables, functions and reusable code such as how to define your own functions and even modules. Now is the perfect time to progress into a key area in programming, data structures.
At the stage you have been working with the basics of Python and writing your own scripts. Everything you’ve learned so far has been building to this point, this is the next stage in your path to Python success. Welcome to Data Structures.
This stage is where we will look at the built-in ways that we have to store and organize our data. Each way we look at serves a distinct purpose and has its own use cases as well as functions.
Welcome back to the Python Roadmap to Success, where I am giving all my readers a fair chance at learning Python the right way, following a proven roadmap that I’ve structured and taught for over the last four years.
In our last article, we covered the tenth phase in the Roadmap to Success, it covered working with built-in Python Modules. This lesson will be a breath of fresh air as you already have a good understanding of the fundamentals, it’s time to introduce a new topic.
In this lesson, you are going to learn two of the four built-in data structures that Python has to offer. I have ensured that these go in order as this is the same path I take my students through one on one. We will look at Lists and Tuples to get started.
Every week you’ll be introduced to a new topic in Python, think of this as a mini starter course to get you going and allow you to have a structured roadmap that actually builds to create you a solid foundation in Python. Join us today!
You know that variables are used to store a single value, typically this value could change. But many times we want to store more than one value, and often it may even be multiple values of different types of data. This is why we work with data structures.
Over the last 8+ years I’ve been teaching full-time around the world which has given me the unique opportunity to work with over 1,500+ students. The last four years I’ve been teaching Python full-time. Breaking down complex topics, step by step.
I’ve spent this time curating a structured learning path that ensures my students have the greatest chance of success and don’t just learn but actually master Python as well as their logical thinking and problem solving.
In this article, we’re going to look at two data structures. These being lists and tuples. Lists are the most common and easy to work with data structures as they allow us to get introduced to this new topic with ease. Tuples are similar but with important key differences we will look at.
One point I should note is, spend time digesting these when I write them, after six weeks most of my posts are automatically put behind a paywall.
If you haven’t subscribed to my premium content yet, you should definitely check it out. You unlock exclusive access to all of these articles and all the code that comes with them, so you can follow along!
Plus, you’ll get access to so much more, like monthly Python projects, in-depth weekly articles, the '3 Randoms' series, and my complete archive!
I spend a lot of my week on these articles, so if you find it valuable, consider joining premium. It really helps me keep going and lets me know you’re getting something out of my work!
Thank you for allowing me to do work that I find meaningful. This is my full-time job so I hope you will support my work by joining as a premium reader today.
If you’re already a premium reader, thank you from the bottom of my heart! You can leave feedback and recommend topics and projects at the bottom of all my articles.
👉 I genuinely hope you get value from these articles, if you do, please help me out, leave it a ❤️, and share it with others who would enjoy this. Thank you so much!
P.S - Drop any questions in the comments or feel free to DM me directly as I’m always happy to help you guys out.
What is a List?
Simply put Data Structures are ways that we organize and structure data in programming. In Python we have four built-in data structures that are quite common to see and use. They each serve a different purpose and can do different things.
We will start off with looking into lists. These are the best way to get started with data structures as they can do so much but we can also use these to get started with more advanced applications and programs than we are used to.
Now a list is basically a list of items. We can add items to the list, edit items, and delete items. You can think of a shopping list for this. This means we can create a single variable and add as many values as we want to the list.
A list is ordered, changeable, and they allow for duplicate values. I made those bold as they will be important to remember as we look at other data structures.
Other key features include the fact that list items are indexed, the first item has index [0]
, the second item has index [1],
etc. Oh, and when I say that lists are ordered, I just mean that the items have a defined order, and that order will not change.
So If we add new items to a list, the new items will automatically be placed at the end of the list. This also means since lists are indexed, lists can have items with the same value.
Read the last few sentences again, these are all important features of a list. There are two ways we define a new list. The first is by simply using the square brackets [ ], any time you see these brackets I want you to think about lists.
The other way is to use the Python list()
function. This is good for new empty lists and also allows us to nest functions to work with lists. There are some functions you can look into such as map, split, input. Think about how these can be used.
👉 I genuinely hope you get value from these articles, if you do, please help me out, leave it a ❤️, and share it with others who would enjoy this. Thank you so much!
How Do We Use a List?
Really to define a list is rather straight forward. We just make a variable, which will be the name of the list, then the value is set to a pair of square brackets []
or the list()
function we spoke about.
If you have data to begin with we use the square brackets, otherwise you can use either of the options to make the list. Below is a quick way to view a list and get specific elements from the list. Remember we can index a list so we can access values.
The above is a perfect starter on how to get started with the pure basics of lists, now I cover all these data structures in a lot more detail through interactive lessons and code challenges to help make sure you understand each step in my Python Masterclass.
Since you have wrapped your head around the basics we can now look at some functions (methods) we use to work with lists. You will use these often and should get comfortable with them.
I am only going to touch on a few but these ones will be the most crucial for your development. With time you will naturally pick up the others and as you should be self studying you will see them.
In order to add an element to a list we need to use append()
. Append just means “to add” so we can append an item. The opposite of append would be remove()
, here you can specify a specific element to delete.
Now another way we could delete an item is pop()
, but pop just pops off the last element in the list. Then finally remember a list is ordered but this also means we can sort the list.
If we use the sort()
method this will automatically sort your list from A - Z or if we are dealing with numbers it will sort from smallest to greatest number so this is real handy in the long run.
I will let you take a moment to read through the code I have above, but this is how all this looks if we write out a script to run. Remember to start trying this and practicing on your own because that is going to make all the difference!
👉 I genuinely hope you get value from these articles, if you do, please help me out, leave it a ❤️, and share it with others who would enjoy this. Thank you so much!
Ready to Take Your First Steps with Python?
Most people get stuck before they even start. But you don’t have to!
I’ve put together a Free Course: The Pure Basics of Python that covers the very basics of Python, made just for beginners like you.
👉 I’m giving you my exact system that’s been proven and tested by over 1,500 students over the last 4+ years!
Here’s what you’ll learn:
✅ Step-by-step help to set up VS Code and install Python.
✅ Learn how to use variables, built-in functions, and even nesting functions.
✅ A quick test to see how much you’ve picked up.
✅ My handcrafted Python Guide to keep you on track.
This free course is a perfect first step — you’ll get a feel for my teaching style and build confidence to keep going.
👉 Ready to get started?
P.S. — If you like the free course (and I think you will!), I’ll show you how to dive deeper with my full Python Masterclass.
🎁 - Get a free one-on-one coaching session with any Masterclass!
Go through the entire Masterclass, complete all material, and attend the Q&A's, if you still feel like your struggling I'll personally work with you one-on-one until you're confident!
What is a Tuple?
Now this one will be straightforward and easier as you have been introduced to lists. I start with lists because they are more commonly used, but Tuples build perfectly onto this.
Remember what a list is? Lists are ordered, changeable, and they allow duplicate values. The real key takeaway you should aim to remember is that a list is changeable.
A tuple is a collection of data that is ordered and unchangeable. This is so important, you can not change a tuple once you make it, it is a way to store data that you do not want to change.
Think of it like a RGB color. RGB stands for Red Green Blue. The scale starts at 0 and goes to 255. So for the color red you would have (255, 0, 0). Now even if you change one of those numbers the color would be different.
The RBG reference is great as this is also a tuple, and a great way to see how we create a tuple. We can use either a set of parentheses ()
or the tuple()
function.
You can see the tuple in code above. This is how it all looks in action, now I have also included the only two methods that work with tuples, these are count()
and index()
.
Also note that these work for both lists and tuples. Long story short, count()
will return the number of times an element occurs in the tuple. Then index()
then takes an element and returns what index (position) the element first occurs.
Guys, I have covered two important data structures to get your heads wrapped around these topics. I want you to spend some time this week trying to write out your own programs to included these two data structures.
👉 I genuinely hope you get value from these articles, if you do, please help me out, leave it a ❤️, and share it with others who would enjoy this. Thank you so much!
My Best Starter Resources
Here are the best resources I have to offer to get you started with Python no matter your background! Check these out as they’re bound to maximize your growth in the field.
Code with Josh: This is my YouTube channel where I post videos every week designed to help break things down and help you grow.
Zero to Knowing: My Python Masterclass platform designed from 8 years teaching experience and that has helped over 1,500+ students succeed with Python. (All my readers unlock a limited time, 25% discount, use code: learnpython25)
My Books: Maybe you’re looking to get a bit more advanced in Python. I’ve written 3 books to help with that, from Data Analytics, to SQL all the way to Machine Learning.
The Nerd Nook: This is where you are right now! I write here multiple times per week with the sole goal of breaking down this larger than life topic to help you excel and learn Python faster than you thought was possible.
This article will be a piece to a larger roadmap but will go behind a paywall after 6 weeks! To help support my work in teaching others consider joining as a premium reader to unlock all these articles, monthly Python projects and in-depth dives.
Wrapping Up Lesson Eleven
You’ve made real progress by getting into data structures. Lists and tuples might look simple at first, but they’re a big part of how we work with groups of data in Python.
Lists let you add, change, or remove things whenever you need to, while tuples are used when you want to keep things the same once they’re set. Knowing when to use each one is a skill that’ll really help as you move into the more advanced stuff later on.
And remember—don’t just read the examples. Try them out. Write your own code, mess around with lists and tuples, and get some real practice in. That’s how it all starts to click. We’re taking this one step at a time, and if you stick with it, you’ll be surprised at how far you’ll go.
If you're enjoying this step-by-step roadmap, be sure to check out the premium version. You’ll get access to full-length tutorials, real-world Python projects, downloadable code, and deeper lessons that help you truly master the material.
Let’s keep moving forward with Day #12 next week.
Hope you all have an amazing week nerds ~ Josh (Chief Nerd Officer 🤓)
👉 If you’ve been enjoying these lessons, consider subscribing to the premium version. You’ll get full access to all my past and future articles, all the code examples, extra Python projects, and more.