[Python] Getting error with turtle.bgcolor() in Python

Discussão em 'Python' iniciado por Stack, Setembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to use turtle to create a square, while tryng to give a color to the turtle window a color "black". I am getting errors, any input will be helpful.

    Below is my code:

    import turtle

    def draw_square():
    window = turtle._Screen
    window.bgcolor("black")


    brad = turtle.Turtle()
    brad.forward(100)
    window.exitonclick()

    draw_square()


    Below is what I get in error:

    color = self._bgcolor(color)

    AttributeError: 'str' object has no attribute '_bgcolor'

    Continue reading...

Compartilhe esta Página