-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (31 loc) · 1.13 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from turtle import Turtle, Screen
import pandas
screen = Screen()
screen.title("U.S. States Game")
img = "blank_states_img.gif"
screen.addshape(img)
map = Turtle()
map.shape(img)
data = pandas.read_csv("50_states.csv")
state_list = data.state.to_list()
data = pandas.read_csv("50_states.csv")
# print(state_list)
correct_guesses = []
while len(correct_guesses) < 50:
answer_state = screen.textinput(title=f"{len(correct_guesses)}/50", prompt="What´s another state´s name")
answer_state = answer_state.title()
if answer_state == "Exit":
missing_states = [item for item in data.state if item not in correct_guesses]
df = pandas.DataFrame(missing_states)
df.to_csv("missing_states.csv")
break
if answer_state in state_list:
state_coordinate = data[data.state == answer_state]
state_x = state_coordinate.x.item()
state_y = state_coordinate.y.item()
correct_guesses.append(answer_state)
writer = Turtle()
writer.hideturtle()
writer.penup()
writer.goto(state_x, state_y)
writer.write(answer_state)