D is for dictionaries - Python A to Z 0 ▲ Juha-Matti Santala 2 hours ago · 6 min read1278 words · Tech · hide · 0 comments Python A-Z is a blog series about Python. Each day, I share insights, ideas and examples for different parts of Python development that match with the letter of the day. Blaugust is an annual blogging festival in August where the goal is to write a blog post every day of the month. Dictionary is a data structure in Python that in other contexts and languages is called an associative array, akey-value store or a map. It’s a handy and efficient data structure for when you need to store and retrieve a value based on a key. This is a 101 level introduction to dictionaries. Dictionary Creating a dictionary The basic form of dictionary can be created in couple of ways: # dict constructor with keyword arguments scores = dict(Charlie=10, Patty=25, Snoopy=30) # dict constructor with tuples scores = dict(('Charlie', 10), ('Patty', 25), ('Snoopy', 30)) # key: value pairs scores = { 'Charlie': 10, 'Patty': 25, 'Snoopy': 30 } # dict comprehension data = [('Charlie', 10), ('Patty', 25), ('Snoopy',… No comments yet. Log in to reply on the Fediverse. Comments will appear here.