Chapters
Python114 chapters

Exercises

List Methods

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

Exercise 1

Use the list as a stack: push a and b, then pop and print the top item.

Python
stack = []
# push two items, then pop and print one
print(stack)
Exercise 2

Print the sum, the smallest and the largest of the numbers.

Python
numbers = [4, 1, 3]
# print sum, then min, then max
Exercise 3

Print the list reversed without changing the original.

Python
original = [1, 2, 3]
# print the reversed version, then the untouched original