Capital city
Log in om je oplossingen te testen.
# Capital city program
# -------------------------
# Subprograms
# -------------------------
def check_answer(country, city):
if country == "England" and city == "London":
return True
if country == "France" and city == "Paris":
return True
else:
return False
def capital_cities():
correct = False
while not correct:
city = input("What is the capital city of England? : ")
correct = check_answer("England", city)
correct = False
while not correct:
city = input("What is the capital city of France? : ")
correct = check_answer("France", city)
# -------------------------
# Main program
# -------------------------
capital_cities()
print("The quiz is complete.")
Je kunt zo vaak indienen als je wenst. Er wordt enkel rekening gehouden met je laatst ingediende oplossing.
Log in om je oplossingen te testen.
Python sandbox
In dit venster kan je Python-code uitvoeren zonder iets te moeten installeren. De code die je hier schrijft wordt niet automatisch ingediend in Dodona.