Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
False
qux
['bar', 'baz']
foo
['quux', 'baz', 'foo']


Delete element in Python List

Code Block
a = [1, 2, 3, 4, 5]

# option 1 - delete element 3
del a[2]

# option 2 - delete element 3
a.remove(3)

# option 3 - delete element 3
a[2:3] = []


Tuple

Info

The tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.

...