0
I have a problem with this code, It outputs syntax error on line 1, I can't figure out what is wrong, help?
class Point(): def __init__(self, x=0, y=0): self.x = x self.y = y self.coords = (self.x, self.y) def move(self, x, y): self.x += x self.y += y def __add__(self, p): return Point(self.x + p.x, self.y + p.y) def __sub__(self, p): return Point(self.x - p.x, self.y - p.y) def __mul__(self, p): return self.x * p.x + self.y * p.y def __str__(self): return "(" + str(self.x) + ',' + str(self.y) + ')' p1 = Point(3,4) p2 = Point(3,2) p3 = Point(1,3) p4 = Point(0,1) p5 = p1 + p2 p6 = p4 - p1 p7 = p2*p3 print(p5, p6, p7)
6 Respostas
+ 1
Your code contains invalid characters that came when you copy/paste the text. You can see them if you save the code in SoloLearn and then view the code in a web browser.
+ 1
Kristian Purgar. Member Ipang is right. Just rewrite the code in solo editor and everything will be ok!
0
remove () in class Point():
0
It still gets a syntax error back?
0
Okay thank you!
0
Great job. Unfortunatelly it is big problem also during the wrie comercial code. When you parse some text and visualy is the same but in char code the different hexadecimal representation