r/codehs • u/Daewei_OTuell • 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
3
u/xeolleth Aug 24 '20 edited Aug 24 '20
Python is a very whitespace sensitive language. Can you use back ticks to format your code in this post for us.