Here is the problem discription: print(snake_array[0].x) AttributeError: 'list' object has no attribute 'x' . I cannot find the mistake
class Test:
def __init__(self, x, y, dir):
self.x = x
self.y = y
self.dir = dir
def snake_init(snake_array):
snake_array.append([Test(300, 300, "RIGHT")])
snake_array.append([Test(301, 300, "RIGHT")])
snake_array.append([Test(302, 300, "RIGHT")])
print(snake_array[0].x)
snake_array = []
snake_init(snake_array)
source https://stackoverflow.com/questions/73859470/here-is-the-problem-discription-printsnake-array0-x-attributeerror-list
Comments
Post a Comment