Top "Dictionary" questions

A dictionary maps keys to values allowing efficient retrieval of values by keys.

Create a dictionary with list comprehension

I like the Python list comprehension syntax. Can it be used to create dictionaries too? For example, by iterating over …

python dictionary list-comprehension dictionary-comprehension
How to create dictionary and add key–value pairs dynamically?

From post: Sending a JSON array to be received as a Dictionary<string,string> I’m trying to …

javascript dictionary key-value
How can I initialise a static Map?

How would you initialise a static Map in Java? Method one: static initialiser Method two: instance initialiser (anonymous subclass) or …

java dictionary collections initialization idiomatic
How to print a dictionary's key?

I would like to print a specific Python dictionary key: mydic = {} mydic['key_name'] = 'value_name' Now I can check …

python dictionary key
How do I sort a list of dictionaries by a value of the dictionary?

I have a list of dictionaries and want each item to be sorted by a specific value. Take into consideration …

python list sorting dictionary data-structures
Creating a new dictionary in Python

I want to build a dictionary in Python. However, all the examples that I see are instantiating a dictionary from …

python dictionary
How to do associative array/hashing in JavaScript

I need to store some statistics using JavaScript in a way like I'd do it in C#: Dictionary<string, …

javascript dictionary hashtable
Converting Dictionary to List?

I'm trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} …

python list dictionary
How can I get dictionary key as variable directly in Python (not by searching from value)?

Sorry for this basic question but my searches on this are not turning up anything other than how to get …

python dictionary key
How do I print the key-value pairs of a dictionary in python

I want to output my key value pairs from a python dictionary as such: key1 \t value1 key2 \t value2 …

python dictionary