Python 3 Programming Tutorial - Multi-dimensional List

sentdex · Beginner ·🛠️ AI Tools & Apps ·11y ago

Key Takeaways

Creates a multi-dimensional list in Python 3

Full Transcript

What's going on everybody? Welcome to another Python 3 Basics tutorial video. In this video, what we're going to be talking about is multi-dimensional lists. So, all the lists that we've covered so far have been a singular dimension, right? So, there's just for each um bit of data in the list, it's only one bit of data. But actually, you can have lists within lists uh within lists within lists if you want. You can go as deep as you want. You can get very uh convoluted fast. Um, so anyway, what we're going to be showing today is a two-dimensional list and then you could take it from there if you so chose. So with that, let's go ahead and get started. So, uh, let's say we have a list and right now like a typical list, don't forget your square brackets. Let's just say we have, uh, the can't get away from these massive numbers. This is our list for now. Okay. Uh, and in fact, let's make that shorter, otherwise I'm going to cry. So, we have this list right now. So, we've got a five, a six, a six, and a two. So let's just make this a seven and two. Um so what we can do now this is a one-dimensional list but what we can do is we can make it a two-dimensional list. So each element in this list is just actually another list. So five and six and then we have a six and a seven and then a seven and a two and then a two and a five. Anybody see what I did there? Probably not. Anyway, continuing on. Um, so now we have a two-dimensional list. So for one, we can just print x. Save and run that. Apparently it's this is uh really challenging. There we go. Okay. So here's our list. Now uh let's say we want to print the first element here. It's a six and a seven. Now what if we wanted to go even deeper? Well, we can go deeper uh using the same sort of syntax. So we can say we want the first element or the zeroith element which will be hopefully a six. Right? We have 67. The first of that is a six. Save and run it and we get a six. So that's how we can reference that. Now we could go even further, right? So this is a two-dimensional list. We could take this even further and say like these numbers here, this could be a list as well. And then we could have another list here. Um, then another list. Let me make sure I've done this right. This gets messy very fast, which is what I'm about to talk about here. Um, 66 and then 78. Um, we'll leave it like that for now. We don't actually have to go further. Let me make sure that's a valid list. Okay. So, um, so this printed now you can see this is, you know, two elements. So, let's say, you know, you want to go even further. Well, obviously we still can go further. So the zeroth of the zeroith again a six. Now as you can see you just typing this out was a kind of a pain. Also just visually looking at it it's kind of a pain to look at this. Uh so what you can do when you make big lists like this is um see like with Python we don't have to have very nice standards necessarily all the time. It kind of Python like forces us into having standards. So as a programmer you maybe forget the fact that you might need to program your own standards. Again, what I mean by standards is the organization of all the text here. So, but what you can do with lists, tupils, um, well, really a whole bunch of stuff, but mostly you're going to do it with lists is you can do the following. You can hit enter. And now this is the, you know, I'm pointing to the screen. You can't see that. Uh, so like this is our our opening bracket. And then we might as well put our closing bracket right down there as well. And then this is our second bracket here. And if you ever want to know um you know what each bracket corresponds to uh you can kind of you can do this. Oops. You can delete it and add it and you can see how it highlights everything. That's kind of how you know like what that bracket corresponds to. So if you're used to like like say you code in like Notepad++ sometimes it does it automatically for you if you like highlight the little bracket especially like curly braces. Say you're programming I don't know PHP or something you highlight them and it kind of corresponds. So if you ever want to know like what bracket that is or if you've actually closed everything you could just do that. Um so anyway then we can see you know these are their own little pair and then this is a group here and then you can either put the commas at the bottom or I like to leave them at the end like this. Um I'm pointing at the screen again you can't see like this at the end here because uh you can go like this and then everything is nice and organized and then do it one more time. This didn't have any lists within a list, so it's not as all pretty and organized, but you get the idea. Um, so we can still run this though, and Python, you know, still deals with it and handles it just like you would hope. Um, and then here, let me show you that. We'll run it. Same thing. So, you can add spaces and it's okay. So, if you, you know, if you're kind of OCD about making everything look pretty, um, you can get away with it. So, anyway, uh, that's just some an example of multi-dimensional lists. Again, you can go as deep into this as you want and it just helps to organize. God, just keep pointing at this screen. I need to like a camera behind me so you guys can see what I'm pointing at. Um, you can organize it like this. And obviously, as you get more and more dimensions, it's going to get almost impossible, right? Because your screen is, you know, still only two dimensions. So, as soon as you get past a two-dimensional list, you're kind of screwed again. But anyway, uh, it does help to kind of organize it a little bit. So, that's going to conclude uh this video. If you guys have any questions or comments, please feel free to leave them below. As always, thanks for watching. Thanks for all the support and subscriptions.

Original Description

In this Python 3 programming tutorial, we cover the multi-dimensional list. Up until now, we have focused on single dimensional lists, but this is limiting. In programming, we are able to create lists with infinite depth. Here's how! Sample code for this basics series: http://pythonprogramming.net/beginner-python-programming-tutorials/ Python 3 Programming tutorial Playlist: http://www.youtube.com/watch?v=oVp1vrfL_w4&feature=share&list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

Related AI Lessons

Up next
I Asked ChatGPT to Apply to 500 Jobs (8 Interviews in 48 Hours)
Sabrina Ramonov 🍄
Watch →