return code error python
from turtle import*
from random import randrange
from freegames import square, vector
food = vector(0,0)
snake = [vector(10,0)]
aim = vector(0,-10)
def change(x,y):
aim.x=x
aim.y=y
def inside(head):
return -200<head.x<190 and -200 <head.y <190
def move():
head=snake[-1].copy()
head.move(aim)
if not inside(head) or head in snake:
square(head.x,head.y,9,'red')
update()
a
return
snake.append()
print('snake',len(snake))
if head==food: food.x = randrange(-15,15)*10
food.y = randrange(-15,15)*10
else
snake.pop(0)
clear()
for body in snake:
square(body.x,body.y,9,'green')
square(food.x,food.y,9,'red')
update()
ontime(move, 100)
hideturtle()
tracer(False)
listen()
onkey(lambda:changes(10,0),'right')
onkey(lambda:changes(-10,0),'left')
onkey(lambda:changes(0,10),'up')
onkey(lambda:changes(0,-10),'down')
move()
done()
4
9
File "c:\Users\deoll\Desktop\java\python test\pythontest.py", line 30
else
^
SyntaxError: invalid syntax
PS C:\Users\deoll\Desktop\java>
Thank you!
9
0
Are there any code examples left?
New code examples in category Python
-
Python 2023-04-11 03:04:20
-
Python 2022-03-27 22:40:04 pycharm no module named
-
Python 2022-03-27 22:25:05 assign multiple variablesin one line
-
Python 2022-03-27 22:20:02 levenshtein distance
-
Python 2022-03-27 21:35:09 get text from url python last slash
-
Python 2022-03-27 21:30:30 df concatenate df
-
Python 2022-03-27 21:25:09 python odd or even
-
Python 2022-03-27 21:15:32 python include function from another file
-
Python 2022-03-27 21:10:01 color module python
-
Python 2022-03-27 21:00:27 python tkinter cursor types