Chapters
Python114 chapters

Exercises

Remove Items

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

Exercise 1

Remove Grace by name.

Python
names = ["Ada", "Grace", "Katherine"]
# remove Grace
print(names)
Exercise 2

Take the last item off and print it, leaving the rest in the list.

Python
names = ["Ada", "Grace", "Katherine"]
# print the removed item
print(names)
Exercise 3

Keep only the odd numbers, by building a new list rather than removing while looping.

Python
numbers = [1, 2, 3, 4, 5, 6]
# keep the odd ones
print(numbers)