Python Forum

Full Version: problem with for loops?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is the code:
import turtle
Win = turtle.Screen()
t = turtle.Turtle()

def shape(length, sides):
    for i in (1,sides):
        t.forward(length)
        t.left(360 / sides)

shape(100, 8)
Win.exitonclick()
the problem is that not matter what sides is it only draws the first 2 lines of the shape
thanks in advance
(Sep-26-2018, 06:33 PM)Darbandiman123 Wrote: [ -> ]for i in (1,sides):
I don't think that does what you think that does.

>>> for x in (1, 4):
...   print(x)
...
1
4
Do you mean for i in range(1, sides)?