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, 2019 in Python by Mihir
68 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, 2019 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, 2019 in Python by Faiza
3,205 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, 2019 in Python by Greg
84 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, 2019 in Python by Himanshu
158 views
0 votes
1 answer
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 760 views
0 votes
0 answers
+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 aryya
• 7,350 points
66 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, 2019 in Python by Omkar
• 69,000 points
120 views