Мой профиль
ACTIVITY 31 / 50

Edit a list

Try as many times as you need

Let’s understand

You can change a list after creating it. insert(index, value) adds an item before that position. pop(index) removes and returns an item; without an index it removes the last item. Later indexes shift after removal. Print the list after each change to inspect the order.

Listen to the explanation

Example

bag = ["map", "water"]
bag.insert(1, "torch")
last = bag.pop()
print(last)
print(bag)
YOUR MISSION

Insert "camera" at index 1 in tools. Remove the last item with pop. Print the removed item, then the final list.

I need a hint

Save the value returned by pop. Remember that indexes start at zero.

How to find an error
  1. Read the last line of the error message.
  2. Find the indicated line. Check quotes, parentheses and indentation.
  3. Change one thing and run again.

main.py

4 spaces

Your draft stays in this browser.

Result

Python
Your program’s output will appear here. Click Run.