[garbage][🐍 game]List has no attribute X (or Y)

if dist(snake.vec.x,snake.vec.y,fruit.vec.x,fruit.vec.y) < 12.5:
         snake.score += 1
def addtail(self,x,y):
 for num in range(0,len(self.prevs)):

(I know this code for adding a tail is wrong)
This is the only append(PVector(x,y)) that I have in my program,
but it says “List obj has no attribute x” (for the y is the same), only when I append a second PVector.
It works for the first tail, but when I add the secon tail, I get this error.

Happy New Year! :fireworks::fireworks:

Is this

part of the addtail() function?

o right, this is in the show function where I show head and tail

What line is it saying the error is coming from?

this line. I dont know why

Is the show function called after addTail() or before?

OK, addtail is called after show if i collected a fruit

    prevH = snake.vec
    if dist(snake.vec.x,snake.vec.y,fruit.vec.x,fruit.vec.y) < 12.5:
         snake.score += 1
         #i currently remved addtail but it was here
       #  snake.tail.append[]

Does snake.prevs start off empty (before any fruit is collected)?

yes, and after collecting a fruit I append one PVector
Now I dont have the old code, but its strange as error

Ok, can I see the whole show function for the snake and also where self.prevs is initially declared?

class Snake:
    def __init__(self):
        self.step = 25
        self.vec = PVector(float((500>>1) + (self.step>>1)),float((500>>1) + (self.step>>1)))
        self.score = 0
        self.tail = []
        self.dir = "STOP"
 def Show(self):
        for i in range(0,len(self.tail)):

This should be the code when i got this error

I don’t think self.prevs is ever declared!

OMG my mistake, self.prevs is the actaully tail

non i want to say that i changed name from self.prevs in sefl.tail,
old code: self.prevs, new code : self.tail
But this error is not a problem, now I dont have it anymore

So everywhere is says self.prevs, it is supposed to be self.tail?
(And it still doesn’t work?)

If u want you I can open a new topic and u can help me with the tails that spawns on my head,

Yes, but this problem is gone bc i changed all the code

So you’re basically saying, you fixed one problem but there is still another?

I am saying, the problem disappeared, and idk how.
THe second problem is just if you want to help, or I will continue by myself, bc i translated a code from a c++ ASCII snake (that did last year) to python, but I have this problem with the tails

I wonder why all your Python code posts so far haven’t been properly indented… :confused: