I have a CSV file with the 50 U.S. states and their corresponding ‘x’ and ‘y’ coordinates which I will place on the screen. This is a small sample of what the CSV data looks like:
state,x,y
Alabama,139,-77
Alaska,-204,-170
Arizona,-203,-40
Arkansas,57,-53
California,-297,13
Colorado,-112,20
Connecticut,297,96
I have a reader for the CSV file and a prompt for the user guess, which is displayed onto a screen using the Turtle library:
states_data = pandas.read_csv("50_states.csv")
user_guess = str(screen.textinput(title="Guess the 50 States", prompt="Enter a state's name: "))
I also have an empty list to add each guess to the list if it is correct:
guesses = []
How can I loop through the data in the CSV file and check if the user’s guess matches a value from the ‘state’ column?