from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter a color:\n'red', 'orange', 'yellow', 'green', 'blue', 'purple' ") colors = ["red", "orange", "yellow", "green", "blue", "purple"] y_positions = [-70, -40, -10, 20, 50, 80] all_turtles = [] #Create 6 turtles for turtle_index in range(0, 6): new_turtle = Turtle(shape="turtle") new_turtle.penup() new_turtle.color(colors[turtle_index]) new_turtle.goto(x=-230, y=y_positions[turtle_index]) all_turtles.append(new_turtle) if user_bet: is_race_on = True while is_race_on: for turtle in all_turtles: #230 is 250 - half the width of the turtle. if turtle.xcor() > 230: is_race_on = False winning_color = turtle.pencolor() if winning_color == user_bet: print(f"You've won! The {winning_color} turtle is the winner!") else:
# scoreboard.instruct() screen.onkeyrelease(turtle.move_u, "Up") screen.onkeyrelease(turtle.move_d, "Down") game_is_on = True car = CarManager() cars = car.create_cars() while game_is_on: time.sleep(0.1) turtle_y = turtle.ycor() game_over = car.move(MOVE_INCREMENT, turtle_y) if game_over: scoreboard.game_over() replay = screen.textinput("You have Squished our turtle friend", "Enter 1 to restart, 2 to continue 3 to quit:") if replay == "1": car.done() scoreboard.restart() car.create_cars() turtle.restart() screen.listen() elif replay == "2": turtle.restart() scoreboard.gameon() screen.listen() else: turtle.bye()
colors = ["red", "orange", "yellow", "green", "blue", "purple"] turtles = {} y_coordinate = -100 for color in colors: turtles[color] = Turtle(shape="turtle") turtles[color].color(color) turtles[color].penup() turtles[color].goto(x=-230, y=y_coordinate) y_coordinate += 50 screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput( title="Make your bet", prompt="Which turtle will win the race? Enter a color: ") print(user_bet) is_race_on = False if user_bet: is_race_on = True while is_race_on: for key in turtles: if turtles[key].xcor() > 230: is_race_on = False winning_color = turtles[key].pencolor() if winning_color == user_bet: print(f"You've won! The {winning_color} turtle is the winner") else:
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title="Turtle Racing Game", prompt="Who's going to win:") colors = ("red", "orange", "green", "yellow", "blue", "purple") all_turtles = [] print(user_bet) for turtle_index in range(0, 6): new_turtle = Turtle(shape="turtle") new_turtle.color(colors[turtle_index]) new_turtle.pu() new_turtle.goto(x=-230, y=-100 + (turtle_index * 30)) all_turtles.append(new_turtle) print(all_turtles) if user_bet: is_race_on = True while is_race_on: for turtle in all_turtles: if turtle.xcor() > 230: is_race_on = False winning_color = turtle.pencolor()
from turtle import Turtle, Screen import random screen = Screen() screen.setup(500, 400) user_bet = screen.textinput("Make your bet!", "Which turtle will won the race? Enter a color: ") colors = ["red", "orange", "yellow", "green", "blue", "purple"] positions = [-125, -75, -25, 25, 75, 125] turtles = [] for i in range(6): new_turtle = Turtle("turtle") new_turtle.color(colors[i]) new_turtle.penup() new_turtle.goto(-230, positions[i]) turtles.append(new_turtle) is_on = False if user_bet: is_on = True while is_on: for turtle in turtles: if turtle.xcor() > 220: is_on = False if turtle.pencolor() == user_bet: print( f"You have won, the \"{turtle.pencolor()}\" turtle is the winner!"
for names, x in data["x"].items(): new_dict[names] = [x] for names, y in data["y"].items(): new_dict[names].append(y) city_names = [] for names, values in new_dict.items(): new_dict[names] = tuple(values) city_names.append(names) #setting screen screen = Screen() screen.title("US MAP") screen.bgpic("Day 025/us-states-game-start/blank_states_img.gif") pen = Turtle() pen.hideturtle() pen.penup() right_names = [] while len(right_names) < len(city_names): city = screen.textinput(title="city",prompt= "Name a city on the map to stop write 'stop': ") if new_dict.get(city): pen.goto(new_dict[city]) right_names.append(city) pen.write(f"{city}", align = "center", font= ("Courier", 10, "normal")) if city == "stop": break screen.exitonclick()
from turtle import Turtle, Screen import random # Game settings is_race_on = False screen = Screen() screen.title("The Great Turtle Race!") screen.setup(width=500, height=400) # Get user guess user_selection = "" while not user_selection: user_selection = screen.textinput( title="Who will win?", prompt= "Which turtle will win the race?\nType blue, green, red, orange, turquoise, or purple.\nEnter a color: " ) # Setup turtle objects after input colors = ["blue", "green", "turquoise", "orange", "red", "purple"] turtles = [Turtle(shape="turtle") for turtle in range(6)] for i in range(6): turtles[i].color(colors[i]) turtles[i].penup() turtles[i].goto(x=-230, y=-100 + (i * 40)) # Start race! result = Turtle() result.penup() result.hideturtle() result.goto(x=0, y=100)
is_race_on = False colors = ['red', 'green', 'yellow', 'orange', 'blue', 'purple'] y_positions = [150, 100, 50, 0, -50, -100] turtles = [] for i in range(len(colors)): tim = Turtle(shape="turtle") tim.color(colors[i]) tim.penup() tim.goto(x=-230, y=y_positions[i]) turtles.append(tim) user_bet = screen.textinput( title="Make your bet", prompt="Which turtle will win the race? Enter your color: " "\n(red, green, yellow, orange, blue, purple)") if user_bet: is_race_on = True while is_race_on: for turtle in turtles: if turtle.xcor() > 230: is_race_on = False wining_color = turtle.pencolor() if wining_color == user_bet: screen.textinput( f"Thanks for Playing", prompt= f'\nYou won! The {wining_color} turtle is the winner\n' f'Did you enjoy playing?')
screen = Screen() screen.title("U.S. States Game") image = "blank_states_img.gif" screen.addshape(image) turtle.shape(image) data = pandas.read_csv("50_states.csv") states_list = data.state.to_list() guessed_states = [] while len(guessed_states) < 50: answer_state = screen.textinput( title=f"{len(guessed_states)}/50 States Correct", prompt="What's the next State's name?").title() state_data = data[data.state == answer_state] if answer_state in states_list: t = Turtle() t.hideturtle() t.penup() t.goto(int(state_data.x), int(state_data.y)) t.write(answer_state) guessed_states.append(answer_state) # print(guessed_states) if answer_state == "Exit": for st in guessed_states: states_list.remove(st)
import random from turtle import Turtle, Screen screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title="Make Your Bet", prompt="Which turtle will win the race? Enter Colour:") print(user_bet) colours = ["red", "green", "blue", "purple", "orange", "yellow"] Y_pos = [-70, -40, -10, 20, 50, 80] is_race_on = False all_turtle = [] for turtle_ind in range(0, 6): tim = Turtle(shape="turtle") tim.color(colours[turtle_ind]) tim.penup() tim.goto(x=-240, y=Y_pos[turtle_ind]) all_turtle.append(tim) if user_bet: is_race_on = True while is_race_on: for turtle in all_turtle: if turtle.xcor() > 230: is_race_on = False winning_colour = turtle.pencolor() if winning_colour == user_bet: print(f"You have won! {winning_colour} is the winning turtle.") else : print(f"You have lost! {winning_colour} is the winning turtle.")
# setting the gif as the new shape for the turtle image = "blank_states_img.gif" screen.addshape(image) screen_turtle = Turtle() screen_turtle.shape(image) tim = Turtle() tim.penup() tim.hideturtle() # reading the csv file using pandas data = pd.read_csv("50_states.csv") states_list = data.state.to_list() user_guess_list = [] while len(user_guess_list) < 50: user_input = screen.textinput( title=f"{len(user_guess_list)}/50 States Correct", prompt="What's another state name?").title() if user_input == "Exit": break elif user_input in user_guess_list: pass elif user_input in states_list: current_state = data[data["state"] == user_input] x = int(current_state["x"]) y = int(current_state["y"]) tim.goto(x, y) tim.write(user_input, move=False, align="center", font=FONT) user_guess_list.append(user_input) missing_states = [] for state in states_list: if state not in user_guess_list:
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(500, 500) user_inp = screen.textinput(title="Make bet", prompt="Fill you bet turtle color: ") turtle_colors = ["red", "green", "blue", "pink", "yellow", "orange"] y_positions = [-100, -60, -20, 20, 60, 100] all_turtles = [] for turtle_index in range(0, 6): new_turtle = Turtle(shape="turtle") new_turtle.color(turtle_colors[turtle_index]) new_turtle.penup() new_turtle.goto(-240, y_positions[turtle_index]) all_turtles.append(new_turtle) if user_inp: is_race_on = True while is_race_on: for turtle in all_turtles: # 230 because each turtle width is 40 and last coordinate is 250. Therefore winning coordinate is 250-(40/2) if turtle.xcor() > 230: is_race_on = False winning_turtle_color = turtle.pencolor() if winning_turtle_color == user_inp: print( f"You have won the bet. Winning Turtle Color is {winning_turtle_color}" )
from turtle import Turtle, Screen import random screen = Screen() screen.setup(width=500, height=400) choice = screen.textinput(title='Turtle Racing', prompt='Which Turtle will win the race?') turtle_color = ['red', 'green', 'blue', 'yellow', 'orange', 'purple'] turtle_list = [] startpos = -100 for value in range(len(turtle_color)): the_color = turtle_color[value] turtle_name = Turtle(shape='turtle') turtle_name.color(the_color) turtle_name.penup() turtle_name.goto(x=-230, y=startpos) startpos += 30 turtle_list.append(turtle_name) still_race = False if choice: still_race = True while still_race: for turtle in turtle_list: if turtle.xcor() > 230:
screen = Screen() screen.setup(width=500, height=400) turtle_line = Turtle() turtle_line.hideturtle() turtle_line.penup() turtle_line.goto(209, 160) turtle_line.pendown() turtle_line.setheading(-90) turtle_line.forward(170) turtle_line.penup() turtle_line.goto(-210, 160) turtle_line.pendown() turtle_line.forward(170) turtle_bet = screen.textinput( "Make your bet", "Which turtle will when the race? Choose color: ") winner = '' race_over = False while not race_over: for turtle in turtles: turtle.forward(randint(5, 16)) if turtle.position()[0] >= 210.0: race_over = True winner = color[turtles.index(turtle)] break if turtle_bet.lower() == winner.lower(): print("Nice bet. The winner is {w}".format(w=winner)) else: print("Sorry. The winner is {w}".format(w=winner))
screen = Screen() screen.title("U.S. States Game") img = "blank_states_img.gif" screen.addshape(img) shape(img) def get_mouse_click_coor(x, y): print(x, y) onscreenclick(get_mouse_click_coor) game_play = True lives = 3 score = 0 while lives > 0: ans = screen.textinput(f"What's another state's name?", f"{score}/50 States Correct\n{lives} lives remaining...").lower() if ans == "exit": break elif ans in dict_states: score += 1 state_text = Turtle() state_text.hideturtle() state_text.penup() state_pos = dict_states.get(ans) state_text.goto(state_pos) state_text.write(ans, True) answers.append(ans) del dict_states[ans] else: lives -= 1
# import the necessary libraries from turtle import Turtle, Screen import random # Create custom screen screen = Screen() screen.setup(width=600, height=500) guess = screen.textinput( title="Who will throw better", prompt="Guess which turtle will throw longer distance?") colors = ["red", "orange", "blue", "green", "purple"] turtles = [] y_positions = [-85, -60, -35, -10, 15, 40, 65] # Create multiple turtles and ask them to throw for turtle_index in range(0, 5): new_turtle = Turtle(shape="turtle") new_turtle.penup() new_turtle.color(colors[turtle_index]) new_turtle.goto(x=-285, y=y_positions[turtle_index]) turtles.append(new_turtle) # Check whether user given guessed color as input dist = {} if guess: for turtle in turtles: rand_throw = random.randint(0, 500) turtle.fd(rand_throw)
def main(): # initialize screen screen = Screen() screen.title("Snake") screen.tracer(0) # ask for user inputs for window size and snake speed chosen_grid = screen.textinput( "Welcome to Snake!", "Choose a window size (small/medium/big): ") insane_choice = screen.textinput("Welcome to Snake!", "Insane mode? (yes/no)") if insane_choice == "yes": speed = 1 insane_mode = True else: speed = screen.numinput("Welcome to Snake!", f"Choose a speed (1-{len(speeds)}): ") insane_mode = False # initialize food, snake and scoreboard chosen_size = grids[chosen_grid]["size"] food = Food(grids[chosen_grid]["grid"]) snake = Snake(chosen_size) scoreboard = ScoreBoard(chosen_size) if insane_mode: insane_writer = InsaneMode(chosen_size) # setup screen of the chosen size, color, title width = height = grids[chosen_grid]["size"] screen.setup(width=width, height=height) screen.bgcolor("black") screen.title("Snake") # updates screen to show snake, first food piece and scoreboard screen.update() # main loop # stops when snake collides with itself or obstacles while snake.is_alive(): # checks for collision with food and updates food position if necessary # also increments scoreboard score according to difficulty if snake.head.distance(food) < 15: snake.lenght += 1 food.update() scoreboard.score += int(grids[chosen_grid]["multiplier"] * speed) # increments difficulty on insane mode if insane_mode and speed < 12: speed += 1 insane_writer.level += 1 # listen to user key presses screen.listen() screen.onkey(fun=snake.turnUp, key="Up") screen.onkey(fun=snake.turnDown, key="Down") screen.onkey(fun=snake.turnLeft, key="Left") screen.onkey(fun=snake.turnRight, key="Right") screen.onkey(fun=screen.bye, key="Escape") # update snake, scoreboard, insane lvl and screen snake.update() scoreboard.update() screen.update() if insane_mode: insane_writer.update() # loop delay / speed control time.sleep(speeds_dict[speed]) # game over screen scoreboard.game_over() screen.textinput("Game Over", "Press any key to play again") snake.reset() scoreboard.reset() screen.clear() main()
import pandas screen = Screen() screen.title("U.S state Game") image = "blank_states_img.gif" screen.addshape(image) turtle.shape(image) pen = Turtle() data = pandas.read_csv("50_states.csv") end_game = False state_count = 0 while not end_game: answer_state = screen.textinput(title=f"{state_count}/50 correct", prompt="What's another state name") if state_count == 50 or answer_state.title() == "Exit": end_game = True state_row = data[data["state"] == answer_state.capitalize()] if len(state_row) == 0: pass else: state_name = state_row["state"].values state_xcor = state_row["x"] state_ycor = state_row["y"] pen.penup() pen.setpos((int(state_xcor), int(state_ycor))) pen.write(state_name[0], align="center") state_count += 1 screen.exitonclick()
# # # screen.listen() # # screen.onkey(counter_clockwise, "a") # screen.onkey(forward, "w") # screen.onkey(backward, "s") # screen.onkey(clockwise, "d") # screen.onkey(clear, "c") start_race = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput("Turtle Race - Place bet", 'What turtle will win? Enter color: ') colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'] y_positions = [-70, -40, -10, 20, 50, 80] turtles = [] for index in range(0, 6): new_turtle = Turtle(shape='turtle') new_turtle.color(colors[index]) new_turtle.penup() new_turtle.goto(x=-230, y=y_positions[index]) turtles.append(new_turtle) if user_bet: start_race = True
from turtle import Turtle, Screen import random colours = ["red", "orange", "yellow", "green", "blue", "purple"] ordinates = [-100, -60, -20, 20, 60, 100] screen = Screen() screen.setup(width=500, height=400) prediction = screen.textinput( title="Make your bet", prompt="Which turtle will win the game? Type the colour") sara_kachua = [] for i in range(0, 6): tim = Turtle(shape="turtle") tim.color(colours[i]) tim.penup() tim.goto(x=-230, y=ordinates[i]) sara_kachua.append(tim) if prediction in colours: not_game_over = True else: print("You had entered wrong command. Please try again") while not_game_over: for i in range(0, 6): kachua = sara_kachua[i] distance = random.randint(0, 10) kachua.forward(distance) if kachua.xcor() > 200: if kachua.pencolor() == prediction:
from snake import Snake from food import Food from scoreboard import Scoreboard import time # Setup the screen screen = Screen() screen.setup(width=600, height=600) screen.bgcolor("black") screen.title("Snake Game") screen.tracer(0) snake = Snake() food = Food() scoreboard = Scoreboard( screen.textinput(title="Snake Name", prompt="What is your name?")) # Set the listeners screen.listen() screen.onkey(snake.up, "Up") screen.onkey(snake.down, "Down") screen.onkey(snake.left, "Left") screen.onkey(snake.right, "Right") # Play the game game_is_on = True steps = 0 while game_is_on: # Refresh the screen screen.update() time.sleep(0.1)
# Store all the correctly guessed states guessed = [] # Keep track of the correctly guessed states score = Turtle() score.hideturtle() score.penup() score.goto(100, 200) while len(guessed) < 36: score.clear() score.write(f"{len(guessed)}/36", font=("courier", 24, "bold")) # Take user input and convert it into title case user_answer = screen.textinput("Guess the State", "Name a state or UT: ").title() # Grabs the row of the user guessed state state_data = data[data["states"] == user_answer] # Exit condition if user_answer == "Exit": # Check all the guessed states and append missing states to the list # for state in all_states: # if state not in guessed: # missed.append(state) # Make the above code concise using list comprehension missed = [state for state in all_states if state not in guessed] print(missed) break
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=600, height=500) # make custom screen user_input = screen.textinput( title="Make a bet.", prompt="Which turtle wll win the race? Enter a color: ") colors = [ "deep pink", "crimson", "purple", "dark orange", "sea green", "deep sky blue" ] y_positions = [-85, -60, -35, -10, 15, 40, 65] all_turtle = [] # to append each new turtle in the list for turtle_index in range(0, 6): new_turtle = Turtle(shape="turtle") new_turtle.penup( ) # penning up as we dont wanna see turtle lines while moving new_turtle.color(colors[turtle_index]) # moving the turtle to end of the window new_turtle.goto(x=-285, y=y_positions[turtle_index]) all_turtle.append(new_turtle) if user_input: # checks whether the user decided the winning turtle is_race_on = True while is_race_on: for turtle in all_turtle: # each turtle in list would be randomly moved
from turtle import Turtle, Screen import random is_race_on = False colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'] screen = Screen() screen.setup(width=500, height=400) screen.bgpic('turtle.png') user_bet = screen.textinput(title="Make Your Bet", prompt="Which Turtle Will Win The Race? Pick A Color: ") y_position = [-80, -50, -10, 30, 60, 90] all_turtles = [] for turtle_index in range(0, 6): new_turtle = Turtle(shape='turtle') new_turtle.color(colors[turtle_index]) new_turtle.penup() new_turtle.goto(x=-230, y=y_position[turtle_index]) all_turtles.append(new_turtle) if user_bet: is_race_on = True while is_race_on: for turtle in all_turtles: if turtle.xcor() > 230: is_race_on = False winning_color = turtle.pencolor() if winning_color == user_bet: print(f'Congratulations! The {winning_color} is the winner!')
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title='Make your bet', prompt='Which turtle will win the race? Enter a color: ') colors = ["red", "orange", "yellow", "green", "blue", "purple"] all_turtles = [] for i in range(6): turtle_y = i*50 - 125 new_turtle = Turtle(shape='turtle') new_turtle.penup() new_turtle.color(colors[i]) new_turtle.goto(x=-230, y=turtle_y) all_turtles.append(new_turtle) if user_bet: is_race_on = True while is_race_on: for turtle in all_turtles: if turtle.xcor() > 230: is_race_on = False winning_color = turtle.pencolor() if winning_color == user_bet: print(f"You've won! The {winning_color} turtle is the winner")
from turtle import Turtle, Screen import random screen = Screen() screen.setup(width=500, height=400) user_color = screen.textinput( title="Make Your Bet", prompt="Which turtle will win the race?? Enter the color: ") turtleList = ['red', 'orange', 'blue', 'green', 'yellow', 'purple'] x = -230 y = -150 turtle_dict = {} for tut in turtleList: turtle_dict[tut] = Turtle('turtle') turtle_dict[tut].penup() turtle_dict[tut].color(tut) turtle_dict[tut].goto(x=x, y=y) y += 60 is_race_on = True while is_race_on: for tut in turtleList: turtle_dict[tut].pendown() if turtle_dict[tut].xcor() > 220: is_race_on = False if user_color == tut: print(f"You've won, {tut} color turtle won the race.") else: print(f'Opps {tut} color turtle won the race.') pass move_value = random.choice(range(0, 11))
def go_again(): from turtle import Turtle, Screen import random # Size on screen size = 2 # screen declaration and canvas size screen = Screen() screen.setup(width=(500 * size), height=(400 * size)) # Turtle Attributes colors = ["purple", "red", "yellow", "blue", "orange", "green", "cyan"] # Turtle Colors colors_attribute = [ "purple", "red", "yellow", "blue", "orange", "green", "cyan" ] # Turtle Y axis starting position position = -150 # Turtle attributes, generated with the names in the colors list for x in range(len(colors)): colors[x] = Turtle() colors[x].hideturtle() colors[x].penup() colors[x].speed(10) colors[x].shape("turtle") colors[x].color(colors_attribute[x]) colors[x].shapesize((1.5 * size)) colors[x].goto(x=-200 * size, y=position * size) colors[x].showturtle() position += 50 # User bet, prompt user_bet = screen.textinput( title="Make your bet", prompt=("Which turtle will win the race? Enter Color between \n" f"{colors_attribute}: ")) x = 0 while 1 > x: for turtle in colors: if turtle.xcor() > (220 * size): x += 1 winning_turtle = turtle.pencolor() if winning_turtle == user_bet: print( f"You've won, the winning turtle was {turtle.pencolor()}" ) user_play_again = screen.textinput( title="Play again", prompt=f"You won, The winning turtle was " f"{turtle.pencolor()} " f"Do you want to play again? y / n: ") else: print(f"You lost, winning turtle was {turtle.pencolor()}") user_play_again = screen.textinput( title="Play again", prompt=f"You lost, the winning turtle was " f"{turtle.pencolor()} " f"Do you want to play again? y / n: ") if user_play_again == "y": screen.clear() go_again() random_pace = random.randint(0, 10) turtle.forward(random_pace) screen.exitonclick()
from turtle import Turtle, Screen import random as rd screen = Screen() screen.setup(width=500, height=400) bet = screen.textinput( title="Make your bet", prompt="Which turtle will win the race? Please enter the color: ") colors = ("red", "orange", "yellow", "green", "blue", "purple") turtles = [] for colour in colors: tim = Turtle(shape="turtle") tim.color(colour) turtles.append(tim) x_coordinate = -200 y_coordinate = 200 for turtle in turtles: y_coordinate -= 50 turtle.penup() turtle.goto(x=x_coordinate, y=y_coordinate) def check_if_final_is_reached(): for turtle in turtles: if turtle.xcor() >= 200: print(bet) if turtle.color()[0] == bet: screen.title("You won!") else:
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:
from turtle import Turtle, Screen, exitonclick from random import randint racers = [] colors = ["blue","red","yellow","pink","green"] screen = Screen() screen.setup(width=500, height=500) user_bet = screen.textinput(title="who will win?",prompt= "('blue','red','yellow','pink','green'): ") y = 200 brush = Turtle() brush.penup() brush.goto(200,200) for i in range(5): racers.append(Turtle(shape="turtle")) racers[i].color(colors[i]) racers[i].penup() y = y - 50 racers[i].setpos(-200, y) brush.pendown() brush.goto(200,y - 50) brush.hideturtle() brush.penup() brush.goto(-50,0) is_end = True if user_bet: is_end = False while not is_end: