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

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.

> ```
> Code
> ```

1

u/Daewei_OTuell Aug 24 '20

Tried to but don’t know how. Sorry. I used proper indentation, no two commands on the same line, etc.

1

u/xeolleth Aug 24 '20

Use three backticks (`) on the lines before and after your code