Chapters
Python114 chapters

Exercises

Join Lists

3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.

Exercise 1

Join the three lists into one, without changing any of them.

Python
first = [1, 2]
second = [3]
third = [4, 5]
# print the combined list
Exercise 2

This raises TypeError. Print the numbers joined by commas.

Python
numbers = [1, 2, 3]
print(", ".join(numbers))
Exercise 3

Build a 3 by 2 grid of zeros where changing one cell does not change the others.

Python
grid = [[0] * 2] * 3
grid[0][0] = 99
print(grid)