> For the complete documentation index, see [llms.txt](https://dailyjournal.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dailyjournal.gitbook.io/notes/languages/python/data-structures.md).

# Data Structures

## List

* Lists in Python represent ordered sequences of values.
* Lists are "mutable", meaning they can be modified "in place".

```python
# list of integer type
primes = [2, 3, 5, 7]

# list of string type
planets = 
    ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']

# list of lists
hands = [['J', 'Q', 'K'], ['2', '2', '2'], ['6', 'A', 'K']]

# list of different types
my_favourite_things = [32, 'raindrops on roses', help]
```

### Slicing

```python
planets[0:3]    #['Mercury', 'Venus', 'Earth']
planets[:3]     #['Mercury', 'Venus', 'Earth']
planets[3:]     #['Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']
planets[1:-1]   #['Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus']
planets[-3:]    #['Saturn', 'Uranus', 'Neptune']
```

## Tuple

## Set

## Dict

## Collections

### namedtuple

* Immutable

### deque

### Counter

### OrderedDict

### defaultdict

{% embed url="<https://devopedia.org/python-data-structures>" %}
