Python List Tuple and Set
In Python, lists, tuples, and sets are all data structures that can be used to store collections of data.
List
- Definition: A list is an ordered collection of items that are mutable (i.e., you can change their contents).
- Syntax: Lists are defined using square brackets
[]
.
- Characteristics:
- Allows duplicate elements.
- Elements can be of different data types.
- Supports indexing and slicing.
- Commonly used methods:
append()
, extend()
, insert()
, remove()
, pop()
, clear()
, index()
, count()
, sort()
, reverse()
.