+ 6

Pls help showing error

class Vector2D: def __int__(self, x, y): self.x = x self.y = y def __add__(self, other): return Vector2D(self.x + other.x, self.y + other.y) first = Vector2D(5, 7) second = Vector2D(3, 9) result = first + second print(result.x) print(result.y)

27th Dec 2020, 1:21 PM
VṢtēphen
VṢtēphen - avatar
2 Antworten
+ 2
you wrote: def _int_.... SHOULD BE def __init__(self,x,y): ... Just missing the 'i' in init man
27th Dec 2020, 1:24 PM
Slick
Slick - avatar
+ 3
Thanks
27th Dec 2020, 1:35 PM
VṢtēphen
VṢtēphen - avatar