Python Programming Tutorial #8 - Lists and Tuples
Skills:
Python for Data90%
Key Takeaways
This video tutorial covers the basics of lists and tuples in Python, including creating, accessing, and modifying list elements, as well as introducing tuples as a separate data type.
Full Transcript
hey guys welcome back to the eighth video in my Python Programming Series today we're going to be talking about list Now list can be fairly complex uh but they are a very important part of python and they are very important to understand so a list is another data type so before we talked about strings integers booleans and floating decimal points so floats um and today we're going to talk about lists so lists again are their own data type so let's just start off by doing an example right now so pretty much uh a list which is denoted by the square brackets here uh is a collection of different data types it could be the same data types or it can be different data types so for an example I'm going to put a apple in here in my list I'm going to put a comma and I'm going to add another item so maybe we'll put a pair and then maybe we'll put a number as well okay so we have the list fruits and in the list we have three items um now everything here separated by a comma is known as an item item so for an example our apple is an item our pair is an item and the integer three is an item now you can see that they're all different data types or sorry there is different data types we have two strings and we have one integer value um now this is fine you can store um different data types in one list um okay so now let's just print the list to the console so we can see what it looks like print it out and you'll see we simply get what exactly what we've typed uh into the idle so we get apple pair and three now if we want to access an individual item in the list we need to do something um a little different so right now we just printed out the whole list but say we want to just print out pair um now what we're going to do is we're going to use the square brackets so we're going to do the list name so fruits and then we're going to put square brackets right beside it no spaces and then inside of the square bracket we're going to type in what's known as the indic of that item um so the way indices work in Python is when you create a list everything is automatically assigned in indic um so in this list we have indices 0 through two now it may seem weird that we start at Z instead of one but that's just the way that computers count um and the way that they work so we have to understand that apple is going to be assigned the integer value of zero so the indic zero meaning I would put zero in here if I wanted to access Apple because that's the first element in our list and then we have pair so that's the second element or item um now that's actually going to be represented by one here so fruits one will give us the value of pair and then fruits two will give us the value of three um now this is uh sometimes difficult for some people to understand but just really try to remember that the first item always is zero so if you would like to access the second item in your list you're going to type in one um into the indic thing here okay so I'm just going to run this and show you how this works and you see we get pair okay that's because um we have the first indic which represents the second item which is pair okay um now there's some other things we can do with list as well so if we want to add something to our list there's a few ways that we can do it um the first way uh which is the only one I'm going to show you right now is probably the easiest and simply what we're going to type is fruits followed by the dot uh so a DOT a period and then we're going to type a pen okay now this means to add to the end of the list so inside of a pend I'm going to put the element or the item that I'd like to add so say we want to add uh another fruit let's think of another fruit that we could add maybe a strawberry okay we want to add strawberry into the list I'm just going to get rid of three so it makes more sense okay so right now now in our list up here we have fruits which is a variable name um containing the list that has Apple and pear now we want to add strawberry to the list so let's start off by printing the list before we add it so we'll print off fruits and then we're going to print fruits one more time after we add this item to the list and you see we have the first list which is what we defined originally and then when we added or appended strawberry to the end of it it added it in just like this so that is a way that we are able to add things into a list um by using do append now there is another way um it's known as the slice operator using something called insert um but we're not going to do that right now we're going to talk about the slice operator in a later tutorial so stay tuned for that okay so fruits. aend we've added strawberry um now if we wanted to add another item we could do the same thing and we could do append again and we we could put in another fruit maybe we want to put in a blueberry okay just like that and again we'll see that it does the same thing we have apple pear and then apple pear strawberry blueberry okay um all right so that's it for adding to the list um now what about changing something in our list uh so let's just add right here at the beginning we'll put in Strawberry so we have three items and now let's say we want to change the middle item in our list to a different fruit say we don't like peirs we want to remove it we want to change that so what we're going to do is we're simply going to type the um the name again so fruits followed by the square brackets and then the indic of the item you want to change um so again remember if we want to change pair we're going to use the indic one um not two because this is the way that it works we're going to use one and then we're going to change it to whatever we' like to change it to so say I want to change it to Blueberry I can do that like like so and then again we can print out fruits and we'll see if it works okay so we get apple blueberry and strawberry that's because we've changed uh the item at indic one into blueberry and we've replaced that we replaced Paar with blueberry pretty much okay um so that's how that works for list for changing items again um we you lists are very useful for storing large amounts of information so this is a very small list but in many programs we use something called multi-dimensional list uh which I'm going to talk about again in another tutorial um and yeah so one more thing before we end it here uh there's another data type called a tupal so a tuple um it's kind of hard word to pronounce but it's used for coordinates and it's also used um for things like colors and rectangles angles um it can also be used just to hold information as well but it's a different type of data type um than a list so we're going to talk about it quickly uh okay so a tuple pretty much looks like this so if we set a position and we set it equal to something like this not in square brackets in the regular round brackets and then we simply put um the items in like this now we see we get um it looks very similar to a list the way that it works again we can use different data types so I could put some like hello in here as well um but it does function a little differently and again things like colors we would also store in a tupo so we would use like 255 255 255 that's simply white in uh red green blue colors and again if we print out the type of the color you can see that we get a class tupal okay so I'm not going to go too in depth with the tupal here I just wanted you to understand what they are because we may be using them in some later to tutorials okay so I hope you learned how to use lists and a little bit about tupal today they're going to be important in the next tutorial um so yeah I hope you enjoyed if you did please like And subscribe and I will see you in the next video
Original Description
This is the 8th video in my python programming tutorial series. Today I cover lists and tuples. A list is a collection datatype that can stores multiple values of various data types. To access an element in a list we simply type the list name followed by square brackets (fruits[2]).
Text-Based Tutorial: https://techwithtim.net/tutorials/python-programming/beginner-python-tutorials/lists-and-tuples/
Please do not forget to LIKE the video and SUBSCRIBE for more tutorials and other content daily.
Video Tags:
python,python tutorial,python language,python full course,python course,learn python,learn python programming,python tutorial for beginners,python tutorial 2018,python programming tutorial,python programming language,software development,programming tutorial,tech with tim
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Tech With Tim · Tech With Tim · 9 of 60
1
2
3
4
5
6
7
8
▶
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
A* Path Finding Algorithm(Visualization)
Tech With Tim
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
Python Programming Tutorial #3 - Conditions
Tech With Tim
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
Python Programming Tutorial #6 - For Loops
Tech With Tim
Python Programming Tutorial #7 - While Loops
Tech With Tim
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
Python Programming Tutorial #10 - String Methods
Tech With Tim
How to Overclock a NVIDIA GPU
Tech With Tim
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
Python Programming Tutorial #12 - Functions
Tech With Tim
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
Cool VBS Script to Prank Your Friends!
Tech With Tim
How to Overclock an AMD GPU
Tech With Tim
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
Recursion and Memoization Tutorial Python
Tech With Tim
Ethereum Mining Rig - Hardware Guide
Tech With Tim
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
How to Install Pygame (Windows 8/10)
Tech With Tim
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
Linear Search Algorithm - Python Example and Code
Tech With Tim
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
Binary Search Algorithm - Python Example & Code
Tech With Tim
Pygame Tutorial #5 - Projectiles
Tech With Tim
Pygame Game - Mini Golf
Tech With Tim
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
Pygame Tutorial #6 - Enemies
Tech With Tim
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
How to Create A Message Box in Python - Tkinter
Tech With Tim
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim
More on: Python for Data
View skill →Related Reads
📰
📰
📰
📰
How I Built a Free Online Image & PDF Processing Platform with Vue 3 + FastAPI
Dev.to · IAMUU
I Built a Free AI-Powered YouTube SEO Toolkit With Zero Budget. Here’s What Actually Happened.
Medium · Startup
How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Medium · ChatGPT
How to prepare for Spain civil service TIC exam using AI in 2026
Dev.to · David García
🎓
Tutor Explanation
DeepCamp AI