I am writing a code in pythony, where I want my ball to move on a graph, and save the positions in a list (posx and posy) I made a ball class, but when I call the constructor, I get this error message: 'Ball' object has no attribute 'posx'. This is my code:
class Ball:
def __init__(self,xvelocity=1, yvelocity=1, inx=1,iny=5, posx=[],posy=[]):
self.xvelocity=xvelocity
self.yvelocity=yvelocity
#giving velocity
self.inx=inx
self.iny=iny
#defining starting position
self.posx[0]=self.inx
self.posy[0]=self.iny
ball=Ball()
Do you know why this happens? Thank you for your help.