0

so for an assingment, I needed to make a function. I wanted to do something cool, so I made a thing that makes squares be a random color, and in a random spot, but for some reason, it wont even show a turtle. Here's the code.

import turtle
import random

turt = turtle.Turtle()
turt.speed(100)

def randspotcolor():
  turt.penup()
  turt.goto(
  random.randint(-300,300),
  random.randint(-300,300)
   )
  turt.pendown()
  turt.color(
     random.randint(0,225),
     random.randint(0,225),
     random.randint(0,225)
     )

def square():
  for i in range(4):
    turt.forward(100)
    turt.right(90)
  
def dothething():
  for i in range(4):
    randspotcolor()
    square
24bit
  • 15
  • 3

2 Answers2

0

This is your problem: You need to call function dothething.

Here's the code you need to add to the bottom:

dothething()
0

Your code has two problems:

  1. As @Carictheelf said the dothething() function was not used in the program.

  2. Your turtle() works in floating number color mode. therefore

turt.color(
        int(random.randint(0, 225)),
        int(random.randint(0, 225)),
        int(random.randint(0, 225))
    )

This code throws an error.

Check the documentation of the colormode() function, and change the Colormode to RGB mode. colormode()

Freeman
  • 36
  • 5