Chapters
Python114 chapters

Exercises

Loop Lists

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

Exercise 1

Print each name with its position, numbered from 1.

Python
names = ["Ada", "Grace"]
# print: 1. Ada  then  2. Grace
Exercise 2

Print each name next to its year, walking both lists together.

Python
names = ["Ada", "Grace"]
years = [1815, 1906]
# print each pair
Exercise 3

Remove the even numbers safely by looping over a copy.

Python
numbers = [1, 2, 3, 4]
for n in numbers:
    if n % 2 == 0:
        numbers.remove(n)
print(numbers)