Learn
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"]
- We create a list called
beatles
with 5 strings. - Then, we remove the first item from
beatles
that matches the string"stuart"
. Note that.remove(item)
does not return anything. - 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.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.