Python Dictionary of States
Question: I am writing a program that uses a dictionary of 50 states. This program. will
ask users about 8 questions and after the user answer the questions, it will
out some thing like 'based on your answer, you should live in this state'. it
is a randomized output of state. The questions will loop around until the user
decided to stop. This is what I have thus far. Can you help? Thank you

    
    
     import random
     def main():
            states = {
    
             'Alabama','Alaska','Arizona','Arkansas','California','Colorado',
             'Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho', 
             'Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana',
             'Maine' 'Maryland','Massachusetts','Michigan','Minnesota',
             'Mississippi', 'Missouri','Montana','Nebraska','Nevada',
             'New Hampshire','New Jersey','New Mexico','New York',
             'North Carolina','North Dakota','Ohio',    
             'Oklahoma','Oregon','Pennsylvania','Rhode Island',
             'South  Carolina','South Dakota','Tennessee','Texas','Utah',
             'Vermont','Virginia','Washington','West Virginia',
             'Wisconsin','Wyoming'
        }
    
    
       print('What city are you from')
       city = input()
       print('What is your favorite team?')
       team = input()
       print('What state is close to you?')
       state = input()
       print('What is the name of your Governor?')
       governor = input()
       print('What is the name of your Senator?')
       senator = input()
       print('what is the name of your Sherif?')
       sherif = input()
       print('What is your favorite baseball team?')
       baseball = input()
       print('What is your favorite basketball team?')
       basketball = input()
       print('What is your favorite hockey team?')
       hockey = input()
    
       print ('Base on your answer the state you should live in is:' + states)
    


Answer: First the states you provide is not a dictionary but a set. Try:

    
    
    type(states)
    

For having a random choice. First convert if to a list and then choose as
below.

    
    
    import random
    states_list = list(states)
    choice = random.choice(states_list)
    

So in final line include

    
    
     print ('Base on your answer the state you should live in is: ' + choice)
    

