Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
One possible program:
capitals = {
"france": "Paris",
"japan": "Tokyo",
"egypt": "Cairo",
"brazil": "Brasilia",
}
while True:
country = input("Country (or 'quit'): ").strip().lower()
if country == "quit":
break
city = capitals.get(country)
if city is None:
print("Unknown country")
else:
print(city)