for a homework assignment, i'm trying to make a game that quizzes users on the capitals of each state, kind of like a flashcards game. I've satisfied all requirements for the program with the code below except they want the questions to be in a random order. how can i shuffle the dictionary? I know how to shuffle a list but not a dictionary, as i thought they were already supposed to be in a random order.. yet i get the questions in the same order i typed the keys/values (alphabetical by state)
flashcards = {'ALABAMA': 'MONTGOMERY',
'ALASKA': 'JENEAU',
'ARIZONA': 'PHOENIX',
'ARKANSAS': 'LITTLE ROCK',
'CALIFORNIA': 'SACRAMENTO',
'COLORADO': 'DENVER',
'CONNECTICUT': 'HARTFORD',
'DELAWARE': 'DOVER',
'FLORIDA': 'TALLAHASSEE',
'GEORGIA': 'ATLANTA',
'HAWAII': 'HONOLULU',
'IDAHO': 'BOISE',
'ILLINOIS': 'SPRINGFIELD',
'INDANA': 'INDIANAPOLIS',
'IOWA': 'DES MOINES',
'KANSAS': 'TOPEKA',
'KENTUCKY': 'FRANKFORT',
'LOUISIANA': 'BATON ROUGE',
'MAINE': 'AUGUSTA',
'MARYLAND': 'ANNAPOLIS',
'MASSACHUSETTS': 'BOSTON',
'MICHIGAN': 'LANSING',
'MINNESOTA': 'ST. PAUL',
'MISSISSIPPI': 'JACKSON',
'MISSOURI': 'JEFFERSON CITY',
'MONTANA': 'HELENA',
'NEBRASKA': 'LINCOLN',
'NAVADA': 'CARSON CITY',
'NEW HAMPSHIRE': 'CONCORD',
'NEW JERSEY': 'TRENTON',
'NEW MEXICO': 'SANTA FE',
'NEW YORK': 'ALBANY',
'NORTH CAROLINA': 'RALEIGH',
'NORTH DAKOTA': 'BISMARCK',
'OHIO': 'COLUMBUS',
'OKLAHOMA': 'OKLAHOMA CITY',
'OREGON': 'SALEM',
'PENNSYLVANIA': 'HARRISBURG',
'RHODE ISLAND': 'PROVIDENCE',
'SOUTH CAROLINA': 'COLUMBIA',
'SOUTH DAKOTA': 'PIERRE',
'TENNESSEE': 'NASHVILLE',
'TEXAS': 'AUSTIN',
'UTAH': 'SALT LAKE CITY',
'VERMONT': 'MONTPELIER',
'VIRGINIA': 'RICHMOND',
'WASHINTON': 'OLYMPIA',
'WEST VIRGINIA': 'CHARLESTON',
'WISCONSIN': 'MADISON',
'WYOMING': 'CHEYENNE'}
def main():
incorrect = 0
correct = 0
print('Let\'s play the State\'s game!!')
for b in flashcards.keys():
question = input('What is the capital of ' + b +'? : ')
if question.upper() == flashcards[b].upper():
correct += 1
print('correct!!')
print('Correct: ', correct)
print('Incorrect: ', incorrect)
else:
incorrect += 1
print('oops! that is incorrect')
print('Correct: ', correct)
print('Incorrect: ', incorrect)
main()