Im a begginer and im trying to make a snake using pygame and i ran into this error and i dont understand this erorr
import pygame
from random import randrange
def snake_head(snx,sny,display,red):
pygame.draw.rect(display,red,[snx,sny,49,49])
def grids():
for x in range(12):
for y in range(12):
rect=pygame.Rect(x*blcsize,y*blcsize,blcsize,blcsize)
pygame.draw.rect(display, white, rect, 1)
def mouse(x,y):
pygame.draw.rect(display,white, [x, y, 49, 49])
def the_fucking_tail(headcordlist,tailcount,display,red):
for x in range(tailcount):
print(headcordlist[x][0], headcordlist[x][1])
tailx=headcordlist[x][0]
taily=headcordlist[x][1]
pygame.draw.rect(display,red[tailx,taily,45,45])
pygame.init()
black=(0,0,0)
white=(250,250,250)
red=(250,0,0)
blcsize=50
sny=250
snx=250
snychange=0
snxchange=0
mouscordx=randrange(0,12)*50
mouscordy=randrange(0,12)*50
display=pygame.display.set_mode((600,600))
CLOCK = pygame.time.Clock()
pygame.display.set_caption('azhdars legacy')
icon = pygame.image.load('cobra.png')
pygame.display.set_icon(icon)
runnig=True
display.set_alpha(None)
movment='none'
tailcount=0
headcordslist=[]
while runnig:
#display
display.fill(black)
grids()
mouse(mouscordx,mouscordy)
#mouse check
if [snx,sny]==[mouscordx,mouscordy]:
mouscordx = randrange(0, 12) * 50
mouscordy = randrange(0, 12) * 50
tailcount+=1
#movements
for event in pygame.event.get():
if event.type==pygame.QUIT:
runnig=False
if event .type==pygame.KEYDOWN:
if event.key==pygame.K_RIGHT:
if movment=='left':
pass
else:
movment='right'
snxchange=50
snychange=0
if event.key==pygame.K_LEFT:
if movment =='right':
pass
else:
movment='left'
snxchange =-50
snychange=0
if event.key == pygame.K_UP:
if movment=='down':
pass
else:
movment='up'
snxchange =0
snychange =-50
if event.key == pygame.K_DOWN:
if movment=='up':
pass
else:
movment='down'
snxchange = 0
snychange =50
pygame.time.delay(300)
snx+=snxchange
sny+=snychange
headcords=list([snx,sny])
print(headcordslist)
#print(headcords)
headcordslist.insert(0,headcords)
#print(headcordslist)
headcordslist=list(headcordslist)
if len(headcordslist)>tailcount:
headcordslist.pop()
the_fucking_tail(headcordslist,tailcount,display,red)
snake_head(snx, sny, display, red)
pygame.display.update()