Python - Basics - Nested Lists

preview_player
Показать описание
Welcome to a new Coding Video!!!
----------------------------------------------------------------------------------------------------------------------------

If you like my content, please SUBSCRIBE, Hit the notification bell, and SHARE.
Thank you for your support!!
----------------------------------------------------------------------------------------------------------------------------

For private request, paid basic desktop applications, or just motivation, don't hesitate to contact me at:
----------------------------------------------------------------------------------------------------------------------------

Explanation

1. Syntax
In python, list are defined using two brackets [ ]
Nested lists are lists inside of other lists, so [ [ ], [ ] ]
You can form grids using nested lists.

2. Form
To create nested lists, we need to use nested loops

3. Visualizing
To see the form of a nested list, it is best to use loops to print them

Ex: lst = []
for x in range(5):
tpl = [y for y in range(5)]

for x in lst:
print(x)

# Here we will have 5 rows and 5 columns
# For each x (row), we create a list of 5 columns (y) and add it to the
# Main list.
# The result is a list containing 5 lists.

# When we want to print, we use a loop where x is a list in the main list.

----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------

Tags
#Python #Basics #Nested_Lists
Рекомендации по теме