I am a beginner to python and found a code to draw triangle by Turtle as below code
def drawPolygon(t, vertices):
t.up()
(x, y) = vertices[-1]
t.goto(x, y)
t.down()
for (x, y) in vertices:
t.goto(x, y)
import turtle
t = turtle.Turtle()
t.hideturtle()
drawPolygon(t, [(20, 20), (-20, 20), (-20, -20)])
turtle.done()
1st thing I don't understand is this: (x, y) = vertices[-1]
.
2nd thing I don't understand is this: for (x, y) in vertices:
.