CMSC 201

Lab 7: Practice

2D Lists

Part 1

Take in a number from the user called listNum. Using a foor loop, create a list containing exactly that number of lists inside it. So if the user enters 4, your program should print out:
[ [], [], [], [] ]

Part 2

Given the following list:

myList = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]

Print out each of the inner lists. Your output should look like this:
[1, 2, 3, 4]
[5, 6, 7, 8]
[9, 10, 11, 12]

Part 3

Write a program that finds the sum of a 1D list.

Part 4

Given the following list:

myList = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]

Create a new list where the nth element in the new list is the sum of the nth element of myList. The result should look like this:

[ 10, 26, 41 ]