Posted on

Learn Python Episode #12: Dictionaries

Get The Learn to Code Course Bundle!

Enroll in The Complete Python Course on Udemy!

In this video we will cover dictionaries in Python. In the previous video when we created a list we used square brackets and comma separated values. To create a dictionary we will use curly brackets instead of the square brackets. In a previous video I may have mentioned that we do not use curly brackets in Python, and that was a lie. What I meant is that we don’t need to wrap code blocks in curly brackets like PHP or JavaScript. So, let’s go ahead and define a dictionary.

{"name": "Nick", "age": is 27, "hobby": "code"}

As you can see, instead of just comma separated values we used in the list, the dictionary uses a key and a value separated by a colon. You can access an item in the dictionary like so:

{"name": "Nick", "age": is 27, "hobby": "code"}{"name"}

Python will then print out “Nick.” Dictionaries will be very important when we get to the JSON part of the course, because we will need to parse though a ton of data.

Web –
Subscribe –
Follow for Updates –