Last active
November 6, 2016 15:47
-
-
Save s2t2/89336d674e9860d90b9d07b4ffb05ce8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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