Video 6: Lists Tuples Dictionaries (page 4 of 14) |
While append() adds items to the end of the list, insert() adds items to a specific position.
evens.insert(0, 1) # Insert the number 1 in the 0th index position.
We may also remove items using pop() or remove().
evens.pop(3) # Remove the item contained in the 3rd indexed position
evens.remove(12) # Clear a specific item (not an indexed position)
We may also clear all of the items in a list using clear()
evens.clear()