-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (38 loc) · 1.28 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
37
38
39
40
41
42
43
44
45
import turtle
import pandas
screen = turtle.Screen()
screen.title("Guess_Indian_States_Game")
image = "map.gif"
screen.addshape(image)
screen.setup(600, 715)
turtle.shape(image)
# For reading the mouse click coordinates
# def get_mouse_click_coord(x, y):
# print(x, y)
# turtle.onscreenclick(get_mouse_click_coord)
# turtle.mainloop()
data = pandas.read_csv("states.csv")
all_states = data.state.to_list()
guessed_states = []
while len(guessed_states) < 28:
answer = screen.textinput(title=f"{len(guessed_states)}/28 States Correct",
prompt="State name").title()
# print(answer)
if answer == "Exit":
# missing_states = []
# for state in all_states:
# if state not in guessed_states:
# missing_states.append(state)
# --> List comprehension
missing_states = [state for state in all_states if state not in guessed_states]
new_data = pandas.DataFrame(missing_states)
new_data.to_csv("States_to_learn.csv")
break
if answer in all_states:
guessed_states.append(answer)
t = turtle.Turtle()
t.hideturtle()
t.penup()
state_data = data[data.state == answer]
t.goto(int(state_data.x), int(state_data.y))
t.write(answer)