# Lists & Dictionaries

### Why does python make a reference to a list and not create a new variable?

But why does Python have this whole complicated reference system to begin with.

And will you have to consider list can be huge in our code right here.

It just has three integers that's only a few bytes of your computer's memory.

But say that this was I don't know 4 billion integers instead of just you know these three right here

Then it would be a huge problem to copy that entire list would all four billion values every time you

make a function call right here.

So as a default sort of shortcut it just stores this list once and instead just assigns a really cheap

and easy to handle list of reference to this variable.

And on that list reference gets copied because it's just a few bites and memory it just points to this

### List continuation

You don't have to follow indentation when you are inside a list:&#x20;

![](/files/-LhDqfOo-ZKek9k01BA-)

It's the same for \\&#x20;

### List Recap

![](/files/-LhDr0fbPb9tb2zICYHW)

### Dictionaries

![](/files/-LhcZ1DwW6GMN4O9Kbf5)

Dictionaries don't have order.&#x20;

**Get**

![](/files/-Lhca9JT6zDIlJFIcZXP)

**setdefault**

![](/files/-LhcahzEgGDz8KKksThB)

Example of setdefault

```python
import pprint

message = 'It was a bright cold day in APril, and the clocks were stricking.'
count = {}

for character in message.upper():
    count.setdefault(character, 0)
    count[character] = count[character] + 1

pprint.pprint(count)
```

Output:

{'I': 6, 'T': 4, ' ': 12, 'W': 2, 'A': 5, 'S': 3, 'B': 1, 'R': 4, 'G': 2, 'H': 2, 'C': 4, 'O': 2, 'L': 3, 'D': 3, 'Y': 1, 'N': 3, 'P': 1, ',': 1, 'E': 3, 'K': 2, '.': 1}

![](/files/-LhccwZjdw_PzQqcn4PW)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julienbeaulieu.gitbook.io/wiki/sciences/programming/python/untitled-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
