from turtle import Turtle, Screen
import random
colors = (“Orange”, “Blue”, “Green”)
y_position = (100, 0, -100)
turtles =
window = Screen()
window.title(“Turtles Racer”)
window.setup(700, 400)
window.bgcolor(“#BDCAA6”)
line = Turtle()
line.hideturtle()
line.penup()
line.goto(x=280, y=150)
line.pendown()
line.color(“Red”)
line.pensize(5)
line.goto(x=280, y=-150)
for info in range(3):
racer = Turtle(“turtle”)
racer.turtlesize(2)
racer.penup()
racer.color(colors[info])
racer.goto(x=-250, y=y_position[info])
turtles.append(racer)
user_choice = window.textinput(title=“Make your bet”,
prompt=“Guess the winner:\nType a color: Orange, Blue or Green ?”).capitalize()
def race_turtles():
race = True
while race:
for turtle in turtles:
if turtle.xcor() > 280:
race = False
winning_turtle = turtle.pencolor()
return winning_turtle
else:
turtle.forward(random.randint(1, 5))
def winner_message():
if user_choice in colors:
message = Turtle()
message.hideturtle()
if user_choice.capitalize() == race_turtles():
message.write(“You Win”, align=“center”, font=(“Arial”, 20, “bold”))
else:
message.write(“You Loose!”, align=“center”, font=(“Arial”, 20, “bold”))
race_turtles()
winner_message()
window.exitonclick()