Skip to content

Commit 7f7a169

Browse files
Merge pull request #677 from varsubham/patch-1
Previous code gave error= "speed" is not defined
2 parents 4a83e0e + 399e269 commit 7f7a169

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Koch Curve/koch curve.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,32 @@
66
# function to create koch snowflake or koch curve
77
def snowflake(lengthSide, levels):
88
if levels == 0:
9-
forward(lengthSide)
9+
t.forward(lengthSide)
1010
return
1111
lengthSide /= 3.0
1212
snowflake(lengthSide, levels - 1)
13-
left(60)
13+
t.left(60)
1414
snowflake(lengthSide, levels - 1)
15-
right(120)
15+
t.right(120)
1616
snowflake(lengthSide, levels - 1)
17-
left(60)
17+
t.left(60)
1818
snowflake(lengthSide, levels - 1)
1919

2020

2121
# main function
2222
if __name__ == "__main__":
23-
speed(0) # defining the speed of the turtle
23+
t=turtle.Pen()
24+
t.speed(0) # defining the speed of the turtle
2425
length = 300.0 #
25-
penup() # Pull the pen up – no drawing when moving.
26+
t.penup() # Pull the pen up – no drawing when moving.
2627
# Move the turtle backward by distance, opposite to the direction the turtle is headed.
2728
# Do not change the turtle’s heading.
28-
backward(length / 2.0)
29-
pendown()
29+
t.backward(length / 2.0)
30+
t.pendown()
3031
for i in range(3):
3132
# Pull the pen down – drawing when moving.
3233
snowflake(length, 4)
33-
right(120)
34+
t.right(120)
3435
# To control the closing windows of the turtle
35-
mainloop()
36+
#mainloop()
37+

0 commit comments

Comments
 (0)