Top "Dictionary" questions

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

I'm getting Key error in python

In my python program I am getting this error: KeyError: 'variablename' From this code: path = meta_entry['path'].strip('/…

python dictionary
What is the difference between dict.items() and dict.iteritems() in Python2?

Are there any applicable differences between dict.items() and dict.iteritems()? From the Python docs: dict.items(): Return a copy …

python dictionary python-2.x
Should I use 'has_key()' or 'in' on Python dicts?

I wonder what is better to do: d = {'a': 1, 'b': 2} 'a' in d True or: d = {'a': 1, 'b': 2} d.has_…

python dictionary
How to copy a dictionary and only edit the copy

Can someone please explain this to me? This doesn't make any sense to me. I copy a dictionary into another …

python python-3.x dictionary reference
How to print a dictionary line by line in Python?

This is the dictionary cars = {'A':{'speed':70, 'color':2}, 'B':{'speed':60, 'color':3}} Using this for loop for keys,values in cars.…

python printing dictionary
Collection was modified; enumeration operation may not execute

I can't get to the bottom of this error, because when the debugger is attached, it does not seem to …

c# wcf concurrency dictionary thread-safety
How to check if a map contains a key in Go?

I know I can iterate over a map m by, for k, v := range m { ... } and look for a key …

dictionary go go-map
How do you sort a dictionary by value?

I often have to sort a dictionary, consisting of keys & values, by value. For example, I have a hash …

c# .net sorting dictionary
get dictionary value by key

How can I get the dictionary value by key on function my function code is this ( and the command what …

c# dictionary key
Python list of dictionaries search

Assume I have this: [ {"name": "Tom", "age": 10}, {"name": "Mark", "age": 5}, {"name": "Pam", "age": 7} ] and by searching "Pam" as name, I …

python search dictionary