listplaceloc = doornum-1
coordinatelist[listplaceloc] = turtle.pos()
coordinatelist = [1,2,3,4,5,6,7,8,9,10,11,12,13,13,14,15,16,17,18,19,20,21,22,23,24]
coordlistnum = 0
turtle.goto(coordinatelist[coordlistnum])
coordlistnum +=1
turtle.pendown()
turtle.color("black")
while coordlistnum!= 24:
iter (coordinatelist[coordlistnum])
turtle.goto(coordinatelist[coordlistnum])
coordlistnum += 1
i have tried the iter function, but it said it couldn't be iter'ed
If I understood the question correctly, you're simply trying to iterate over
coordinatelist, which you're doing already. You can simply get rid of theiter (coordinatelist[coordlistnum])because you're already iterating through the list in a while loop by implementing a counter and incrementing it.This means you'll be calling all elements of
coordinatelistuntil you reach element number 24 (elements 1...23, because you've incremented thecoordlistnumonce before going into the loop and because once you increment it to 24 you'll exit the loop)iter()returns an iterator object, which could be valid too, you'll simply have to callnext()on the iterator and catch the exception like so:You're probably better off with a simple for loop while slicing the list to stop at the 23rd element
Or enumerate and use the index and the value and break (exit the loop) once you reach the required index: