Python Turtle Color Change: The color of the line and the color of the arrow keep changing.

Asked 2 years ago, Updated 2 years ago, 82 views

    import turtle
    wm = turtle.Screen()
    t = turtle.Turtle()
    t.penup()
    t.goto(50,50)
    t.pendown()
    t.begin_fill()
    t.color("brown")

    t.forward(100)
    t.left(72)
    t.forward(100)
    t.left(72)
    t.forward(100)
    t.left(72)
    t.forward(100)
    t.left(72)
    t.forward(100)
    t.end_fill()

I want to fill the pentagon with color, but the color of the line and arrow keep changing. How do I keep the lines and arrows black?

python turtle

2022-09-20 22:23

1 Answers

import turtle

t = turtle.Turtle()

t.color('black', 'brown')
t.penup()
t.goto(50,50)
t.pendown()

t.begin_fill()
t.forward(100)
t.left(72)
t.forward(100)
t.left(72)
t.forward(100)
t.left(72)
t.forward(100)
t.left(72)
t.forward(100)
t.end_fill()

t.color('black', 'green')
t.penup()
t.goto(-50,-50)
t.pendown()

t.begin_fill()
t.forward(100)
t.right(144)
t.forward(100)
t.left(72)
t.forward(100)
t.right(144)
t.forward(100)
t.left(72)
t.forward(100)
t.right(144)
t.forward(100)
t.left(72)
t.forward(100)
t.right(144)
t.forward(100)
t.left(72)
t.forward(100)
t.right(144)
t.forward(100)
t.end_fill()

turtle.exitonclick()


2022-09-20 22:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.