Creating a Dictionary | Dictionary
Python Data Structures

Course Content

Python Data Structures

1. List
2. Dictionary
3. Tuple
4. Set

# Creating a Dictionary

A dictionary is a data structure that stores unordered key-value pairs.

Imagine you need to create a dictionary called `student` with these pairs:

 Key Value `'first name'` `'Ann'` `'last name'` `'Elliot'` `'city'` `'New York'`

Check out the code to make this dictionary.

In a dictionary, you can use any immutable data type for a key. For instance, the dictionary we just looked at has strings as keys. Now, let's whip up a dictionary using numbers as keys.

Remember, the value associated with a specific key can be anything — strings, numbers, lists, and so on.

It's time to practice!

`'Colorado':'Rockies', 'Boston':'Red Sox', 'Minnesota':'Twins'`.

Here, `Colorado` is a key, while `Rockies` is its corresponding value, and so forth.

`'Colorado':'Rockies', 'Boston':'Red Sox', 'Minnesota':'Twins'`.

Here, `Colorado` is a key, while `Rockies` is its corresponding value, and so forth.

Everything was clear?

Section 2. Chapter 1

# Creating a Dictionary

A dictionary is a data structure that stores unordered key-value pairs.

Imagine you need to create a dictionary called `student` with these pairs:

 Key Value `'first name'` `'Ann'` `'last name'` `'Elliot'` `'city'` `'New York'`

Check out the code to make this dictionary.

In a dictionary, you can use any immutable data type for a key. For instance, the dictionary we just looked at has strings as keys. Now, let's whip up a dictionary using numbers as keys.

Remember, the value associated with a specific key can be anything — strings, numbers, lists, and so on.

It's time to practice!

`'Colorado':'Rockies', 'Boston':'Red Sox', 'Minnesota':'Twins'`.

Here, `Colorado` is a key, while `Rockies` is its corresponding value, and so forth.

`'Colorado':'Rockies', 'Boston':'Red Sox', 'Minnesota':'Twins'`.

Here, `Colorado` is a key, while `Rockies` is its corresponding value, and so forth.

Everything was clear?

Section 2. Chapter 1

# Creating a Dictionary

A dictionary is a data structure that stores unordered key-value pairs.

Imagine you need to create a dictionary called `student` with these pairs:

 Key Value `'first name'` `'Ann'` `'last name'` `'Elliot'` `'city'` `'New York'`

Check out the code to make this dictionary.

In a dictionary, you can use any immutable data type for a key. For instance, the dictionary we just looked at has strings as keys. Now, let's whip up a dictionary using numbers as keys.

Remember, the value associated with a specific key can be anything — strings, numbers, lists, and so on.

It's time to practice!

`'Colorado':'Rockies', 'Boston':'Red Sox', 'Minnesota':'Twins'`.

Here, `Colorado` is a key, while `Rockies` is its corresponding value, and so forth.

`'Colorado':'Rockies', 'Boston':'Red Sox', 'Minnesota':'Twins'`.

Here, `Colorado` is a key, while `Rockies` is its corresponding value, and so forth.

Everything was clear?

A dictionary is a data structure that stores unordered key-value pairs.

Imagine you need to create a dictionary called `student` with these pairs:

 Key Value `'first name'` `'Ann'` `'last name'` `'Elliot'` `'city'` `'New York'`

Check out the code to make this dictionary.

In a dictionary, you can use any immutable data type for a key. For instance, the dictionary we just looked at has strings as keys. Now, let's whip up a dictionary using numbers as keys.

Remember, the value associated with a specific key can be anything — strings, numbers, lists, and so on.

It's time to practice!

`'Colorado':'Rockies', 'Boston':'Red Sox', 'Minnesota':'Twins'`.
Here, `Colorado` is a key, while `Rockies` is its corresponding value, and so forth.