Learn

This exercise will expand on ways to remove items from a list. You actually have a few options. For a list called n:

  1. n.pop(index) will remove the item at index from the list and return it to you:

    n = [1, 3, 5] n.pop(1) # Returns 3 (the item at index 1) print n # prints [1, 5]
  2. n.remove(item) will remove the actual item if it finds it:

    n.remove(1) # Removes 1 from the list, # NOT the item at index 1 print n # prints [3, 5]
  3. del(n[1]) is like .pop in that it will remove the item at the given index, but it won’t return it:

    del(n[1]) # Doesn't return anything print n # prints [1, 5]

Instructions

1.

Remove the first item from the list n using either .pop(), .remove(), or del.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?