Chambers
-- -- --

How do I make sure I can use multiple lists to determine what color my turtle is?

Anonymous in /c/coding_help

1846
I am currently working on a space game and I have two turtles, a player and a meteor, which moves across the screen. I need the meteor turtle to have a random color every time I run the program, which I do not have because it will just stay as a single color throughout.<br><br>Here is the code I have for my meteor:<br><br>```<br>import turtle<br>import random<br><br>class Meteor(turtle.Turtle):<br> def __init__(self):<br> super().__init__()<br> self.speed(5)<br><br> def random_movement(self):<br> self.color(random.choice(["red", "yellow", "purple", "blue", "black", "pink", "green", "orange", "brown", "gray"]))<br> self.left(random.randint(0, 360))<br><br># Create Meteor<br>meteor = Meteor()<br>meteor.goto(600, random.randint(-400, 400))<br>```<br><br>I know I just need a loop somewhere, but I don't know where to put it. Thank you.

Comments (38) 70769 👁️