⊗pyPmMdLTD 167 of 208 menu

Three-dimensional list in Python

A three-dimensional list looks like this:

lst = [ [ ['a', 'b'], ['c', 'd'], ], [ ['e', 'f'], ['g', 'h'], ], [ ['i', 'j'], ['k', 'l'], ] ]

To display elements from such a list, you need to write three square brackets:

print(lst[0][0][0]) # 'a' print(lst[2][1][0]) # 'k'

The following list is given:

lst = [ [ ['a', 'b'], ['c', 'd'], ], [ ['e', 'f'], ['g', 'h'], ] ]

Print the string 'acfg' from it.

The following list is given:

lst = [ [ [1, 2], [3, 4], ], [ [5, 6], [7, 8], ], ]

Find the sum of all elements in the given list.

byenru