0

I am struggling to make a diamond in python turtle, I have tried to find tutorials but it is not the shape I want.

this is the shape I want. Diamond shape I want:

Can you please help me?

code:

   for _ in range(1):
       turtle.left(60)
       turtle.forward(200)
       turtle.left(120)
       turtle.forward(200)
       turtle.left(120)
       turtle.forward(200)
       turtle.left(150)```
#this just makes a big triangle, I want it to loop back and make another triangle. Help me!
cdlane
  • 40,441
  • 5
  • 32
  • 81
RetroMerc
  • 11
  • 1
  • 1
    When you make the turtle rotate, you use a relative angle (not an absolute one). So the second rotation should be `turtle.left(30)` instead of `turtle.left(120)`, I guess. And correct the following values accordingly. – Laurent LAPORTE Jun 06 '22 at 03:30
  • Please try to think about the problem logically. Where, relative to your example output, do you want the turtle to start? Which line will it draw first? Which way is it facing at the start? Which way does it have to move in order to draw that first line? Therefore, how much will it turn? Now, apply the same reasoning for each subsequent line. Make sure you understand that `turtle.left` *turns* the turtle to the left; it does not choose a direction. Think about how far away the desired new direction is from the current one, in degrees. – Karl Knechtel Jun 13 '22 at 22:26

1 Answers1

1

One simple approach involves less code than you have already:

import turtle

for _ in range(2):
    turtle.left(60)
    turtle.forward(200)
    turtle.left(60)
    turtle.forward(200)
    turtle.left(60)

turtle.done()

The turtle environment is rich enough that there are other ways to go about it, eg.

import turtle

width, height = turtle.window_width(), turtle.window_height()
turtle.setworldcoordinates(-width, -height/2, width, height/2)
turtle.circle(175, steps=4)

turtle.done()
cdlane
  • 40,441
  • 5
  • 32
  • 81