I am trying to create a random triangle in python turtle with a for loop. I figured it out how to complete the task without a for loop, but I was instructed to use a for loop. I am going to add my code that isn't working. I need explanations and examples if that is possible. I what to understand . range is (-r,r) and the starts at the origin. Thank you:
import turtle
import random
turtle.penup()
turtle.color('red')
def median(r):
L = []
for i in range (3):
L.append(randint(-r,r),randint(-r,r))
forward(r)
return L
turtle.pendown()
Aucun commentaire:
Enregistrer un commentaire