Change the snake head color using python turtle

0 votes

I'm using the following code to build the snake game using turtle:

import turtle

#set up the screen
wn = turtle.Screen()
wn.title("snake game")
wn.bgcolor("Blue")
wn.setup(width=600, height=600)
wn.tracer(0)

#Snake Head
head = turtle.Turtle()
head.speed(0)
head.shape("square")
head.color()
head.penup()
head.goto(0, 0)
head.direction = "stop"


# Main game loop
while True:
    wn.update()

turtle.mainloop()

As of now, I've only created a window and added a snakehead. The snakehead color is black. How do I change it to green?

Jun 19 in Python by Mihir
19 views

1 answer to this question.

0 votes

You can et the snakehead color by specifically mentioning it. As of now, you've kept the snakehead color as default. Change the following line in your code:

head.color()

To

head.color("green")
answered Jun 19 by Faiza

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

Change the window background color using turtle - python

Try this: import turtle #set up the screen wn = ...READ MORE

answered Jun 19 in Python by Faiza
49 views
0 votes
1 answer

Snake head placed on the center - Python using turtle

You can use turtle's goto() function. This ...READ MORE

answered Jun 21 in Python by Greg
40 views
0 votes
1 answer

Draw a square using the turtle module - Python

Hey @Baily, use something like this: import turtle sq ...READ MORE

answered Jun 21 in Python by Himanshu
47 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 133 views
+4 votes
6 answers
0 votes
1 answer

How can I rename files on the fly using Python?

You could simply use a wrapper object ...READ MORE

answered Sep 7, 2018 in Python by ariaholic
• 7,320 points
32 views
0 votes
1 answer

How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

answered Jan 2 in Python by Omkar
• 67,120 points
44 views