# Looping and Unpacking with Dictionaries and Tuples

## Looping and Unpacking with Dictionaries and Tuples

### Looping through a Dictionary:

```python
employees = {'mike': 27000, 'john':65000, 'rebeca':6000, 'tom':10000 }

# By default the below for loop is `employees.keys()`
for person in employees:
	print(person) # This will print the KEY of the DICT

for entry in employees.items():
	print(entry)  # This will print the ENTIRE Entry
	
for salary in employees.values():
	print(salary) # This will print the VALUES of the DICT
```

### Unpacking the data:

* `The ability to extract each individual item from a DICT`

```python
employees = {'mike': 27000, 'john':65000, 'rebeca':6000, 'tom':10000 }

# By using both the 'key' and the 'value' of the DICT
for key, value in employees.items():
# We can now print the key and value individually:
	print(key)
	print(value)
```

### Unpacking a list of tuples:

```python
employees = [('mike', 27000, 29), ('john',65000, 29), ('rebeca',6000, 29)('tom',10000, 29)]

for (name, salary, age) in employees:
	print(name)
	print(salary)
```


---

# 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://docs.arkannis.net/programming/courses/python-pcap-31-03-course/control-flow/looping-and-unpacking-with-dictionaries-and-tuples.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.
