tuples multiple assignment with dictionaries combining itemstuple assignmentand foryou can see nice code pattern for traversing the keys and values of dictionary in single loopfor keyval in list( items())print(valkeythis loop has two iteration variables because items returns list of tuples and keyval is tuple assignment that successively iterates through each of the key-value pairs in the dictionary for each iteration through the loopboth key and value are advanced to the next key-value pair in the dictionary (still in hash orderthe output of this loop is againit is in hash key order ( no particular orderif we combine these two techniqueswe can print out the contents of dictionary sorted by the value stored in each key-value pair to do thiswe first make list of tuples where each tuple is (valuekeythe items method would give us list of (keyvaluetuplesbut this time we want to sort by valuenot key once we have constructed the list with the value-key tuplesit is simple matter to sort the list in reverse order and print out the newsorted list {' ': ' ': ' ': list(for keyval in items( append(valkeyl [( ' ')( ' ')( ' ') sort(reverse=truel [( ' ')( ' ')( ' ')by carefully constructing the list of tuples to have the value as the first element of each tuplewe can sort the list of tuples and get our dictionary contents sorted by value