import sys cities_dict={'Beijing': {'Capital': 'China'},'Moscow': {'Capital': 'Russia'},'Paris': {'Capital': 'France'}} for i in cities_dict.keys(): print('{} is the capital of {}!'.format(i,cities_dict.get(i).get('Capital')))