#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Need help with a python function

Member Posts: 1
I have a function that draws a star (this works) and I have to call that function a certain amount of times, given by the input. The colors of the stars have to be generated randomly, the length of each side of the star has to be generated randomly, and the placing (x,y) coordinate of the star. In other words, I have to make a bunch of differently sized, different color stars scattered around the page. Here is what I have and I keep getting a type error saying the type 'int' has no len().

FOR DRAWING THE STAR

def star(color,length,x,y):
turtle.penup()
turtle.color(color)
turtle.goto(x,y)
turtle.forward(length)
turtle.pendown()
count = 0
while (count < 5):
turtle.forward(length)
turtle.right(144)
turtle.forward(length)
count +=1
print (star("black",50,200,-100))

FOR DRAWING SEVERAL STARS

def color():
Question = int(input("How many stars do you want? "))
count = 0
while (count < Question):
rnum = randrange(0,5)
if (rnum == 0):
turtle.color("red")
elif (rnum == 1):
turtle.color("blue")
elif (rnum == 2):
turtle.color("yellow")
elif (rnum == 3):
turtle.color ("green")
else:
turtle.color("black")
turtle.penup()
x = randrange(-280,280)
y = randrange(-200,200)
turtle.goto(x,y)
turtle.pendown()
turtle.color(rnum)
rnum2 = randrange(5,70)
turtle.forward(rnum2)
count += 1
print (star)
print (color())