Respuesta :
Answer:
Explanation:
When deleting anything from dictionary always mention the key value in quotes .
Ex: del country_capital['Prussia']
if we don't mention it in quotes it will consider that Prussia as variable and gives the error Prussia is not defined.
Code:
user_input=input("") #taking input from user
entries=user_input.split(',')
country_capital=dict(pair.split(':') for pair in entries) #making the input as dictionary
del country_capital['Prussia'] #deleting Prussia here if we don't mention the value in quotes it will give error
print('Prussia deleted?', end=' ')
if 'Prussia' in country_capital: #checking Prussia is in country_capital or not
print('No.')
else:
print('Yes.')
print ('Spain deleted?', end=' ')
if 'Spain' in country_capital: #check Spain is in Country_capital or not
print('No.')
else:
print('Yes.')
print ('Togo deleted?', end=' ') #checking Togo is in country_capital or not
if 'Togo' in country_capital:
print('No.')
else:
print('Yes.')
Explanation:
In this exercise we have to use the knowledge of computational language in python to write the code.
This code can be found in the attached image.
How can we described this code?
user_input=input("")
entries=user_input.split(',')
country_capital=dict(pair.split(':') for pair in entries)
del country_capital['Prussia']
print('Prussia deleted?', end=' ')
if 'Prussia' in country_capital:
print('No.')
else:
print('Yes.')
print ('Spain deleted?', end=' ')
if 'Spain' in country_capital:
print('No.')
else:
print('Yes.')
print ('Togo deleted?', end=' ')
if 'Togo' in country_capital:
print('No.')
else:
print('Yes.')
See more about python at brainly.com/question/22841107
