Tried to make somethng with turtle and now im in an endless error, if you want to see it you can run this code on python turtle, its so hard to fix

this is my code-

import turtle
import random

# Set up the turtle
t = turtle.Turtle()
t.speed(0)
t.hideturtle()
turtle.bgcolor("black")

# Define a function to draw a starburst (one arm of the supernova)
def starburst(size, angle, color):
    hex_color = '#' + ''.join(format(c, '02x') for c in color)
    t.pencolor(hex_color)
    for i in range(30):
        t.forward(size)
        t.backward(size)
        t.right(angle)

# Define a function to draw a transparent star
def transparent_star(x, y, size, color, alpha):
    t.penup()
    t.goto(x, y)
    t.pendown()
    t.pencolor(color)
    t.fillcolor(color[0], color[1], color[2], alpha)
    t.begin_fill()
    for i in range(5):
        t.forward(size)
        t.right(144)
    t.end_fill()

# Draw the supernova endlessly
while True:
    x = random.randint(-200, 200)
    y = random.randint(-200, 200)
    t.penup()
    t.goto(x, y)
    t.pendown()
    size = random.randint(50, 200)
    angle = random.randint(10, 80)
    r = random.randint(0, 255)
    g = random.randint(0, 255)
    b = random.randint(0, 255)
    color = (r, g, b)
    starburst(size, angle, color)

    # Draw a random number of transparent stars
    num_stars = random.randint(10, 20)
    for i in range(num_stars):
        r = random.randint(0, 255)
        g = random.randint(0, 255)
        b = random.randint(0, 255)
        color = (r, g, b)
        alpha = 200
        star_size = random.randint(5, 20)
        star_x = random.randint(x-int(size/2), x+int(size/2))
        star_y = random.randint(y-int(size/2), y+int(size/2))
        transparent_star(star_x, star_y, star_size, color, alpha)

    # Fade out the transparent stars
    for alpha in range(200, 0, -10):
        for star in t.turtles():
            if star.pencolor() != (0.0, 0.0, 0.0):
                color = star.fillcolor()
                hex_color = '#' + ''.join(format(c, '02x') for c in color[:3])
                star.fillcolor(hex_color, alpha)
                star.pencolor(hex_color, alpha)
        turtle.delay(20)

    # Erase the transparent stars
    for star in t.turtles():
        if star.pencolor() != (0.0, 0.0, 0.0):
            star.clear()

    # Draw new transparent stars with different colors and positions
    for i in range(num_stars):
        r = random.randint(0, 255)
        g = random.randint(0, 255)
        b = random.randint(0, 255)
        color = (r, g, b)
        alpha = 0
        star_size = random.randint(5, 20)
        star_x = random.randint(-300, 300)
        star_y = random.randint(-300, 300)
        transparent_star(star_x, star_y, star_size, color, alpha)

    # Fade in the transparent stars
    for alpha in range(0, 200, 10):
        for star in t.turtles():
            if star.pencolor() != (0.0, 0.0, 0.0):
                color = star.fillcolor()
                hex_color = '#' + ''.join
1 Like

Welcome to the forums.

Please format your code by triple backticks to make it easier to read.

Also, can you elaborate on your issue?

2 Likes

yes, i ran it and it talked about bad color tuples and bad color strings, i tried fixing it but it still had the error.

this is what i saw:

Traceback (most recent call last):
  File "/home/runner/deep-space/driver.py", line 26, in <module>
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/runner/deep-space/main.py", line 58, in <module>
    transparent_star(star_x, star_y, star_size, color, alpha)
  File "/home/runner/deep-space/main.py", line 24, in transparent_star
    t.pencolor(color)
  File "/nix/store/9kzgdmf4q5vxshisils7pzgc6342pcsy-python3-3.10.0/lib/python3.10/turtle.py", line 2253, in pencolor
    color = self._colorstr(args)
  File "/nix/store/9kzgdmf4q5vxshisils7pzgc6342pcsy-python3-3.10.0/lib/python3.10/turtle.py", line 2697, in _colorstr
    return self.screen._colorstr(args)
  File "/nix/store/9kzgdmf4q5vxshisils7pzgc6342pcsy-python3-3.10.0/lib/python3.10/turtle.py", line 1167, in _colorstr
    raise TurtleGraphicsError("bad color sequence: %s" % str(color))
turtle.TurtleGraphicsError: bad color sequence: (167, 254, 81)
repl process died unexpectedly: exit status 1
Python turtle on Replit