Tag Archives: dictionary

How to sort a dictionary by values in Python

Tweet By definition, dictionary are not sorted (to speed up access). Let us consider the following dictionary, which stores the age of several persons:

If you want to sort this dictionary by values (i.e., the age), you must be … Continue reading

Posted in Python, Uncategorized | Tagged , | Leave a comment

python: how to merge two dictionaries

Tweet Let us suppose two dictionaries storing ages of different individuals:

If you do mind losing the contents of either list1 or list2 variable, you can update one of the other as follows:

Now list1 variable contains:

Continue reading

Posted in Python | Tagged | Leave a comment