Python 2D collections are easy ⬜

Published: 08 November 2022
on channel: Bro Code
48,219
1.3k

#python #tutorial #course

00:00:00 intro
00:06:11 exercise

Here are a few different 2d collection combinations:

2D list of lists
num_pad = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
["*", 0, "#"]]

2D list of tuples
num_pad = [(1, 2, 3),
(4, 5, 6),
(7, 8, 9),
("*", 0, "#")]

2D list of sets
num_pad = [{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{"*", 0, "#"}]

2D tuple of lists
num_pad = ([1, 2, 3],
[4, 5, 6],
[7, 8, 9],
["*", 0, "#"])

2D tuple of tuples
num_pad = ((1, 2, 3),
(4, 5, 6),
(7, 8, 9),
("*", 0, "#"))

2D tuple of sets
num_pad = ({1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{"*", 0, "#"})

2D set of lists (NOT VALID)
num_pad = {[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
["*", 0, "#"]}

2D set of tuples
num_pad = {(1, 2, 3),
(4, 5, 6),
(7, 8, 9),
("*", 0, "#")}

2D set of sets (NOT VALID)
num_pad = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{"*", 0, "#"}}

for row in num_pad:
for num in row:
print(num, end=" ")
print()


Watch video Python 2D collections are easy ⬜ online, duration hours minute second in high quality that is uploaded to the channel Bro Code 08 November 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 48,219 times and liked it 1.3 thousand visitors.