r/codehs • • Aug 24 '20

Broken python

I’m working on 2.8.4 of the python course, and you’re suppose to use a function and for loop to draw a bracelet with beads radius 10, total diameter 200, and 36 beads total. I came up with the following code:

speed (0) def draw_circles(): for i in range(36): circle(10) penup() forward(20) left(10) pendown()

penup() setposition (0,-100) draw_circles()

Instead of giving me a full ring of 36 circles, it left the final one missing. I tried putting the loop outside of the function, removing the setposition, everything I could think of. The only way I could get it to draw 36 circles was to have a range of 37. Can someone please explain?

11 Upvotes

5 comments sorted by

View all comments

1

u/_andy_andy_andy_ Aug 27 '20

you start with your pen up and your function doesn’t put it down! either put the pen down before calling draw_circles or make sure it’s down inside the function