Exercise: Count total number of characters of dictionary keys
Loop through the keys of the capitals dictionary and calculate their total number of characters. Increment the variable num_char by the length of each key in every iteration.
capitals = {
'USA': 'Washington D.C.',
'France': 'Paris',
'Brazil': 'Brasília',
'Peru': 'Lima'
}
num_char = 0
# iterate over keys here...
for
print(num_char)
# expected: 19
Python
Setting up Python environment...
Output