Reputation: 1
I am trying to draw five turtles, but I am getting a TypeError
on line 25. Here is my code:
import turtle
wn = turtle.Screen()
redrose = turtle.Turtle()
color = input("What will your background color be?")
fillcolor_f = input("What will the color of your rose be?")
redrose.hideturtle()
redrose.speed(30)
redrose.penup()
redrose.left(180)
redrose.forward(175)
redrose.right(90)
redrose.forward(30)
redrose.right(90)
redrose.pendown()
def drawRose(red):
redrose.color("pink")
redrose.fillcolor(fillcolor_f)
redrose.fill(True)
for i in range(red):
redrose.forward(i)
redrose.right(49)
for i in range(5):
drawRose(redrose)
redrose.penup()
redrose.forward(350)
redrose.right(144)
redrose.pendown()
redrose.fill(False)
drawRose(50)
wn.bgcolor(color)
I am trying to draw five roses, but it produces errors. I am doing this in interactivepython.org.
Upvotes: 0
Views: 4314
Reputation: 5886
You are recursively calling drawRose
with the wrong parameter. On the line 23 (for i in range(red):
) you expect red
to be an integer, which is it, when first called on line 36 (drawRose(50)
). But then on line 27 (drawRose(redrose)
) you are passing in the redrose
object, which is a turtle. It is not clear to me exactly what you should pass in there. I doubt that you even want to call it recursively. I suspect you actually want another function like drawPetal
.
Upvotes: 2