We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Pop and Peek

Now that we can add items to our stack, we need to be able to view the top item, and remove the top item.

Assignment

Tips

  • The del keyword can be used to remove an item from a list by index.
  • The last item in a Python list can be accessed with the index -1.