How to sum all the values in a dictionary??

Let's say I have a dictionary in which the keys map to integers like: d = {'key1': 1,'key2': 14,'key3': 47} Is th...

How to check if a variable is a dictionary in Python??

How would you check if a variable is a dictionary in python? For example, I'd like it to loop through the values in...

Determining if Swift dictionary contains key and obtaining any of its values?

I am currently using the following (clumsy) pieces of code for determining if a (non-empty) Swift dictionary contain...

How to check if a value exists in a dictionary (python)?

I have the following dictionary in python: d = {'1': 'one', '3': 'three', '2': 'two', '5': 'five', '4': 'four'} ...

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 do this same t...

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 but is there a more efficien...

Merging dictionaries in C#?

What's the best way to merge 2 or more dictionaries (Dictionary<T1,T2>) in C#? (3.0 features like LINQ are fin...

What is the best way to iterate over a dictionary??

I've seen a few different ways to iterate over a dictionary in C#. Is there a standard way? ...

Map values to ArrayList?

I have a Map<Integer, MyClass> and MyClass has 2 fields, Object1 obj and Object2 objj for example. How can I ...

Reverse / invert a dictionary mapping?

Given a dictionary like so: my_map = {'a': 1, 'b': 2} How can one invert this map to get: inv_map = {1: 'a', 2: ...

String to HashMap JAVA?

I have a Java Property file and there is a KEY as ORDER. So I retrieve the VALUE of that KEY using the getProperty()...

How to find if a given key exists in a C++ std::map?

I'm trying to check if a given key is in a map and somewhat can't do it: typedef map<string,string>::iterator...

How to remove a key from a Python dictionary??

When deleting a key from a dictionary, I use: if 'key' in my_dict: del my_dict['key'] Is there a one line way...

convert csv file to list of dictionaries?

I have a csv file col1, col2, col3 1, 2, 3 4, 5, 6 I want to create a list of dictionary from this csv. output a...

How to skip 2 lines in a file with Python??

I have a series of files and I want to extract a specific number from each of them. In each of the files I have this...