Learn
Python Lists and Dictionaries
Remove a Few Things

Sometimes you need to remove something from a list.

beatles = ["john","paul","george","ringo","stuart"] beatles.remove("stuart") print beatles

This code will print:

["john","paul","george","ringo"]
  1. We create a list called beatles with 5 strings.
  2. Then, we remove the first item from beatles that matches the string "stuart". Note that .remove(item) does not return anything.
  3. Finally, we print out that list just to see that "stuart" was actually removed.

Instructions

1.

Remove 'dagger' from the list of items stored in the backpack variable.

Folder Icon

Take this course for free

Already have an account?