-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (40 loc) · 1.56 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
46
import turtle
import pandas
from relevant_locations import RelevantLocations
screen = turtle.Screen()
screen.title("Europe Countries Game")
image = "europe_blank_map.gif"
screen.addshape(image)
turtle.shape(image)
data = pandas.read_csv("europe_countries.csv")
europe_countries = data.country.to_list()
guessed_countries = []
relevant_locations = RelevantLocations()
relevant_locations.add_continents()
relevant_locations.add_seas()
relevant_locations.add_exit_instruction()
while len(guessed_countries) < 41:
answer_country = screen.textinput(title=f"{len(guessed_countries)}/41 Countries Correct",
prompt="What's another country's name?").title()
if answer_country == "Exit":
missing_countries = [country for country in europe_countries if country not in guessed_countries ]
df = pandas.DataFrame(missing_countries)
df.to_csv("countries_to_learn.csv")
break
if answer_country in europe_countries:
if answer_country not in guessed_countries:
guessed_countries.append(answer_country)
t = turtle.Turtle()
t.hideturtle()
t.penup()
country_data = data[data.country == answer_country]
t.goto(int(country_data.x), int(country_data.y))
t.color("#CF0A0A")
t.write(answer_country, font=('Arial', 8, 'bold'))
if len(guessed_countries) == 41:
z = turtle.Turtle()
z.hideturtle()
z.penup()
z.goto(-200, 290)
z.color("#00005C")
z.write("CONGRATULATIONS. YOU WIN !!!", font=('Arial', 18, 'bold'))