From 059dc8f5762fcf518e50cd43ef77239a7e3f7f72 Mon Sep 17 00:00:00 2001 From: pythonboi Date: Wed, 6 Apr 2022 23:57:14 -0400 Subject: [PATCH 1/2] fix append issue --- turtleRace.py | 125 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 51 deletions(-) diff --git a/turtleRace.py b/turtleRace.py index 8900a36..af6a6fa 100644 --- a/turtleRace.py +++ b/turtleRace.py @@ -11,60 +11,83 @@ # Ask a question and Enter you input message -Answer = screen.textinput("Question", prompt="Which turtle color will win the race?") - -print(Answer) +# Answer = screen.textinput("Question", prompt="Which turtle color will win the race?") +# +# print(Answer) rainbowColors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] -Jenny = Turtle() -Jenny.shape("turtle") -Jenny.color("red") -Jenny.penup() -Jenny.goto(-335, 0) - -pam = Turtle() -pam.color("orange") -pam.shape('turtle') -pam.penup() -pam.goto(-335, 30) - -tom = Turtle() -tom.color("yellow") -tom.shape('turtle') -tom.penup() -tom.goto(-335, 60) - -jane = Turtle() -jane.color("green") -jane.shape('turtle') -jane.penup() -jane.goto(-335, 90) - -jim = Turtle() -jim.color("blue") -jim.shape('turtle') -jim.penup() -jim.goto(-335, -30) - -kim = Turtle() -kim.color("indigo") -kim.shape('turtle') -kim.penup() -kim.goto(-335, -60) - -sam = Turtle() -sam.color("violet") -sam.shape('turtle') -sam.penup() -sam.goto(-335, -90) - - -class Select: - def __init__(self, color, shape, position): - self.color = color - self.shape = shape - self.position = position +userNames = ['jenny', 'pam', 'tom', 'jane', 'jim', 'kim', 'sam'] + +colorTaken = [] +nameTaken = [] + + +# for num in range(len(rainbowColors)): +# if num < len(rainbowColors): +# if color not in + + +for pick in userNames: + if pick not in colorTaken: + colorTaken.append(pick) + #getName = +print(colorTaken) + + # for check in userNames: + # if n not in check: + # getName = Turtle() + # getName.shape('turtle') + + +# Jenny = Turtle() +# Jenny.shape("turtle") +# Jenny.color("red") +# Jenny.penup() +# Jenny.goto(-335, 0) + +# pam = Turtle() +# pam.color("orange") +# pam.shape('turtle') +# pam.penup() +# pam.goto(-335, 30) +# +# tom = Turtle() +# tom.color("yellow") +# tom.shape('turtle') +# tom.penup() +# tom.goto(-335, 60) +# +# jane = Turtle() +# jane.color("green") +# jane.shape('turtle') +# jane.penup() +# jane.goto(-335, 90) +# +# jim = Turtle() +# jim.color("blue") +# jim.shape('turtle') +# jim.penup() +# jim.goto(-335, -30) +# +# kim = Turtle() +# kim.color("indigo") +# kim.shape('turtle') +# kim.penup() +# kim.goto(-335, -60) +# +# sam = Turtle() +# sam.color("violet") +# sam.shape('turtle') +# sam.penup() +# sam.goto(-335, -90) +# +# +# class Select: +# def __init__(self, color, shape, position): +# self.color = color +# self.shape = shape +# self.position = position screen.exitonclick() From 37ad02a471cb1a58de6e0032c0d347dde5ebf574 Mon Sep 17 00:00:00 2001 From: pythonboi Date: Sat, 9 Apr 2022 01:17:03 -0400 Subject: [PATCH 2/2] use loop to get more turtle --- turtleRace.py | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/turtleRace.py b/turtleRace.py index af6a6fa..e02f2a1 100644 --- a/turtleRace.py +++ b/turtleRace.py @@ -1,3 +1,4 @@ +import turtle from turtle import Turtle, Screen import random @@ -15,36 +16,43 @@ # # print(Answer) -rainbowColors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] +rainbowColors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo']#, 'violet'] -userNames = ['jenny', 'pam', 'tom', 'jane', 'jim', 'kim', 'sam'] +userNames = ['jenny', 'pam', 'tom', 'jane', 'jim', 'kim']#, #'sam'] + +y_Position = [30, 60, 90, 0, -30, -60, -90] colorTaken = [] nameTaken = [] +# +# def changeRange(x, y): +# global num +# for num in range(0, 6): +# num = num + 10 +# turtle.goto(-335, num) + +for pick in range(0, 6): + + userNames = Turtle() # userNames.shape('turtle') + userNames.shape("turtle") + #userNames.color(pick) + userNames.penup() -# for num in range(len(rainbowColors)): -# if num < len(rainbowColors): -# if color not in + userNames.goto(-335, y_Position[pick]) + userNames.color() + # userNames.goto(changeRange(x, y=num)) -for pick in userNames: - if pick not in colorTaken: - colorTaken.append(pick) - #getName = -print(colorTaken) +# def pickUser(): +# for name in userNames: +# name. - # for check in userNames: - # if n not in check: - # getName = Turtle() - # getName.shape('turtle') -# Jenny = Turtle() -# Jenny.shape("turtle") -# Jenny.color("red") -# Jenny.penup() -# Jenny.goto(-335, 0) + # for n in userNames: + # if n in userNames: + # n.goto(-335, 30) # pam = Turtle() # pam.color("orange")