Skip to content

Instantly share code, notes, and snippets.

@Manuela82
Created November 19, 2017 12:15
Show Gist options
  • Save Manuela82/598da3cbd062ce56d2ce35897745ec65 to your computer and use it in GitHub Desktop.
Save Manuela82/598da3cbd062ce56d2ce35897745ec65 to your computer and use it in GitHub Desktop.
country_capital_dict = {"Slovenia": "Ljubljana", "Croatia": "Zagreb", "Austria": "Vienna"}
def main():
country_capital_dict = {"Slovenia": "Ljubljana", "Croatia": "Zagreb", "Austria": "Vienna"}
while True:
selected_country = country_capital_dict.keys()[0]
guess = raw_input("What is the capital of %s? " % selected_country)
check_guess(guess, selected_country, country_capital_dict)
again = raw_input("Would you like to continue this game? (yes/no) ")
if again == "no":
break
print "END"
print "__________________________"
def check_guess(user_guess, country, cc_dict):
capital = cc_dict[country]
if user_guess == capital:
print "Correct! The capital of %s is indeed %s" % (country, capital)
return True
else:
print "Sorry, you are wrong. The capital of %s is %." (country, capital)
return False
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment