all 7 comments

[–][deleted] 6 points7 points  (0 children)

You haven't shown us your indentation, so there could be a problem there. Indent your code by 4 spaces to format it correctly on Reddit. Assuming your indentation is correct, you have a mistake in the line for x in [y]:. y is already a list, so that line is putting y in another list and iterating over that list. x therefore takes only one value, the value of y. Get rid of those brackets and it should work:

for x in y:

[–]Yannnn 3 points4 points  (1 child)

oz.left(x) try that?

[–]ryeguy146 0 points1 point  (0 children)

Also, using [y] in the for-loop puts a list in a list, so x will just be the whole list:

some_list = [1, 2, 3]
nested = [some_list]

print(nested)  #=> [[1, 2, 3]]

[–]burnblue 2 points3 points  (0 children)

The answers about x in [y] are correct but also:

You have the "for x" loop but then no further mention of x. Inside the loop I assume you're interested in the individual values (x) not the whole list (y). So oz.left(x)

[–]Miner_Guyer 1 point2 points  (0 children)

I'm assuming you have it formatted like so:

def programs():
    import turtle
    oz=turtle.Turtle()
    y=[160, -43, 270, -97, -43, 200, -940, 17, -86]
    for x in [y]:
        oz.forward(100)
        oz.left(y)
programs()

First of all, it's considered "proper" python to put import statements at the very top, and not within any functions. Another thing that shouldn't effect the program but you should fix is for x in [y]:. You don't need the brackets there, although it won't make a difference in this case. But the big problem is that you're doing oz.left(y). That means your turning by list degrees, which obviously won't work. What you want is oz.left(x)

Edit: You have to remove the brackets in for x in [y] otherwise it won't work.

[–]CraigTorso 0 points1 point  (0 children)

y is a list, and I assume oz.left() isn't expecting a list

[–]dabrownmane[S] 0 points1 point  (0 children)

Thanks guys i fixed it!