Hi, I'm using Python 3.1 to write a simple game involving naming state capitols. I think I have some kind of type mismatch but I don't know what it is. I think it's when I compare the player's answer to the real answer, but don't know how to make it right.
from random import *
states = {}
print ("Guess State Capitols")
statefile = open("state capitols.csv")
for line in statefile:
(state,capitol) = line.split(",")
states[state] = capitol
statefile.close()
guessnum = randint(1,50)
names = list(states.keys())
guess = names[guessnum]
print("What is the capitol of " + guess)
playerguess = input()
if playerguess == str(states[guess]):
print("Yes You are right!")
print("No you are wrong")
print(str(states[guess]))
It's at
if playerguess == str(states[guess]):
but I don't know what I am doing wrong, in that even when I have the answer right, it says I'm wrong, but prints the same answer I typed in. I know it's a newbie question, but would appreciate any help. (I also know that the line "no you are wrong" would print in any case, but I'll fix that later).