Remove first element of list

  • pop
  • shift

To remove an element by its index, use the slice syntax:


examples/lists/remove_first_element.py

names = ['foo', 'bar', 'baz', 'moo']

first = names.pop(0)
print(first)    # foo
print(names)    # ['bar', 'baz', 'moo']