-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (30 loc) · 1.08 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from turtle import Turtle, Screen
import random
screen = Screen()
screen.setup(width=500, height=400)
turtle_colors = ["red", "blue", "green", "orange", "yellow", "purple"]
starting_line = [-125, -75, -25, 25, 75, 125]
list_of_turtles = []
# init turtles
for num_of_turtles in range(0, 6):
n_turtles = Turtle(shape="turtle")
n_turtles.color(turtle_colors[num_of_turtles])
n_turtles.penup()
n_turtles.goto(x=-225, y=starting_line[num_of_turtles])
list_of_turtles.append(n_turtles)
# user input
user_input = screen.textinput(title="Place your bet!", prompt="Select the winning turtle! Enter a color: ")
if user_input:
race_cont = True
while race_cont:
for turtle in list_of_turtles:
if turtle.xcor() > 220:
race_cont = False
winner = turtle.pencolor()
if winner == user_input:
print(f"Winner! The {winner} turtle wins!")
else:
print(f"Loser! The {winner} turtle wins!")
run = random.randint(0, 10)
turtle.forward(run)
screen.exitonclick()