Question 1- is it another way to solve the problem?
capitals={'France':'Paris', 'Spain':'Madrid', 'United Kingdom':'London', 'India': 'New Delhi', 'United States':'Washington DC', 'Italy': 'Rome', 'Denmark':'Copenhagen', 'Germany':'Berlin', 'Greece':'Athens', 'Bulgaria':'Sofia'}
user_input= input('Put a country to check: ')
while user_input!= 'exist':
if user_input in capitals:
print(capitals[user_input])
else:
print('it\'s not in the dictionary)
user_input=input('put another a country to check: ')
Hey Tuyen,
Thank you for engaging with the Python Programmer Bootcamp course!
What you have posted is a perfectly working solution. I would only make the following adjustment: the user_input
variable inside the while
-loop could instead read
Put another country to check or type 'exit':
Otherwise, the user wouldn't know how to exit the program :)
Enjoy the rest of the course!
Kind regards,
365 Hristina