For this assignment we will build a dictionary of country properties. The countries form the key to this dictionary. The values of the dictionary are dictionaries themselves that portray the name of a property on the value of that property for the country. Your assignment consists of writing a function that automatically reorganises the data in the format asked.

Assignment

Write a function addCountryProperty that has two obligatory and one optional argument. To the first parameter a string must be given that contains the name of a property (for example capital). To the second parameter a dictionary must be given that portrays the countries on the corresponding values for the property in question. To the optional parameter properties a dictionary can be given. If so, the values for the property must be added to that dictionary. If no value was given to the third parameter, a new dictionary must be made to which the values of the property must be added. The function must print the dictionary of properties as a result.

Example

>>> capitals = {
...     'Belgium': 'Brussels',
...     'Netherlands': 'Amsterdam',
...     'France': 'Paris',
...     'Germany': 'Berlin'
... }
>>> properties = addCountryProperty('capital', capitals)
>>> properties
{
    'France': {'capital': 'Paris'},
    'Belgium': {'capital': 'Brussels'},
    'Nederland': {'capital': 'Amsterdam'},
    'Germany': {'capital': 'Berlin'}
}
>>> population = {
...     'Belgium': 10438353,
...     'Netherlands': 16730632,
...     'France': 62814233,
...     'Germany': 81305856
... }
>>> addCountryProperty('population', population, properties)
{
    'France': {'population': 62814233, 'capital': 'Paris'},
    'Belgium': {'population': 10438353, 'capital': 'Brussels'},
    'Netherlands': {'population': 16730632, 'capital': 'Amsterdam'},
    'Germany': {'population': 81305856, 'capital': 'Berlin'}
}