20th Sep 2018, 6:48 PM
sama baluom
sama baluom - avatar
4 Answers
+ 8
1: it's __init__ not _init_ 2: x and y is not defined use point(1,2) point(x=1, y=2) or x, y = 1, 2 point(x, y) 3: you should use self.x not x.self (first_parameter_name.x) class point: def __init__(self,x,y): self.x = x self.y = y x, y = 1, 2 p1= point(x,y) print(p1.x)
20th Sep 2018, 7:00 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 1
You have to set values in p1=Point(x,y) or variables, BTW: __init__ is with 2 leading and trailing underscores: class Point: def __init__(self, x, y): self.x = x self.y = y p1 = Point(3,4) print(p1.x)
20th Sep 2018, 7:09 PM
aelbler
aelbler  - avatar
+ 1
Here's a correct version of the code. https://code.sololearn.com/c4L9cj2YuOKZ/?ref=app
20th Sep 2018, 7:10 PM
Dlite
Dlite - avatar
+ 1
thanks :)
20th Sep 2018, 7:11 PM
sama baluom
sama baluom - avatar