Skip to content

Instantly share code, notes, and snippets.

@eloidrai
Last active April 19, 2021 17:27
Show Gist options
  • Save eloidrai/74bef045862fbd0659792549729e4695 to your computer and use it in GitHub Desktop.
Save eloidrai/74bef045862fbd0659792549729e4695 to your computer and use it in GitHub Desktop.
Dessine une Courbe du Dragon. Prend 2 paramètres : le nombre d'itérations et la longueur d'un trait.
import turtle
iterations = int(input("Combien d'itérations ? "))
longueur = int(input("Quelle longueur veux-tu pour un trait ? "))
liste=["c"]
for i in range(iterations):
nouvelle_liste=[]
for pliage in range(0,len(liste)):
if pliage%2==0:
nouvelle_liste += ["m",liste[pliage],"c"]
else:
nouvelle_liste += [liste[pliage]]
liste=nouvelle_liste[:]
turtle.forward(longueur)
for tortue in liste:
if tortue == "m":
turtle.right(90)
turtle.forward(longueur)
if tortue == "c":
turtle.left(90)
turtle.forward(longueur)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment