Orchestra task

Report a typo

In an amateur orchestra of programmers, there are two types of instruments: strings and percussion. Information about the instruments and their number is sequentially recorded in two corresponding dictionaries.

from collections import ChainMap


string_instruments = {'violin': 5, 'guitar': 7, 'viola': 2, 'banjo': 1}
percussion_instruments = {'castanets': 4, 'drum': 2, 'tambourine': 3, 'musical triangle': 1}

For convenience, both dictionaries are mapped into one ChainMap object named band.

band = ChainMap(string_instruments, percussion_instruments) 

The conductor of the orchestra wants to analyze the data of the dictionary with percussion instruments in order to understand what other instruments are missing. So, to do this, they need to get the second dictionary from the ChainMap. How could it be done?

Select one or more options from the list
___

Create a free account to access the full topic