Skip to content

Instantly share code, notes, and snippets.

@s2t2
Last active November 6, 2016 15:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save s2t2/89336d674e9860d90b9d07b4ffb05ce8 to your computer and use it in GitHub Desktop.
from random import shuffle
state_capitals = {
"Alaska": "Juneau",
"Arizona": "Phoenix",
"Arkansas": "Little Rock",
"California": "Sacramento"
} # todo: get the rest from the internet
states = state_capitals.keys() #> ['California', 'Arizona', 'Arkansas', 'Alaska']
shuffle(states) # http://stackoverflow.com/questions/976882/shuffling-a-list-of-objects-in-python
correct_response_count = 0
for state in states:
response = input("Please name the capital city of " + state + " (e.g. 'My City'):")
if response == state_capitals[state]:
correct_response_count += 1
print("You answered " + str(correct_response_count) + " out of " + str(len(states)) + " correctly.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment