Nested Lists in Python (Overview) - Python Tutorial for Beginners

preview_player
Показать описание
🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!

🖥️ Nested Lists in Python (Overview)

A list can contain sublists as an item, which in turn can contain sublists themselves, and so on. This is known as Nested Lists in Python. You can use them to arrange data into some hierarchical structures.

# Nested List in Python
my_list = ["mouse", [8, 4, 6], ['a']]

○ How to Access Items from Nested Lists in Python?

Similarly, you can access individual items in a Nested List, using multiple indexes. The first index determines which List to use, and the second indicates the value within that second list. Indexes for the items in a Nested List are illustrated as below.

But, also keep in mind that the deeper you are going to get an item, the more complex it will become, because of its syntax. So, it is sometimes more efficient to use another and more adapted Data Type in Python.

my_list = ['a', 'b', ['cc', 'dd', ['eee', 'fff']], 'g', 'h']

print(my_list[2][2]) # OUTPUT: ['eee', 'fff']
print(my_list[2][2][0]) # OUTPUT: eee

Let's play this video, stick around and watch until the end of this video! 👍🏻

- Digital Academy™ 🎓

***

☞ WATCH NEXT:

#Python #Tutorial #Beginners #Shorts

***

♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.

***

♡ FOLLOW US ♡

♡ SUPPORT US ♡

***
Рекомендации по теме
Комментарии
Автор

Have you ever used Nested Lists in Python? 🤔

DigitalAcademyOnline
Автор

Very useful to understand How Nested Lists in Python work 👍🏻

xJrmy
Автор

Thanks for sharing a New video everyday

chloejbt