+ 1

Invalid syntax

class Geaom(object): def__init__(self,h = 10,w = 10): self.h, self.w = h def rectangle(self): rect = self.h*2 + self.w*2 return rect a = Geom(4) print(a.rectangle()) This is a quiz from python challenge. On idle it show invalid syntax at line 2 def__init__(self, h= 10, w = 10): for this semicolon. why so?

18th Dec 2017, 2:34 PM
Kanhaiya Kr
Kanhaiya Kr - avatar
2 Réponses
+ 2
make this changes- line 2: space between def and _init_ line 3: replace comma (,) with equal to (=) line 7: spelling mistake, it should be "Geaom" line 7: pass 2 arguments instead of 1
18th Dec 2017, 6:20 PM
Ankit Agrawal
Ankit Agrawal - avatar
+ 1
class Geaom(object): def __init__(self,h = 10,w = 10): self.h = self.w = h def rectangle(self): rect = self.h*2 + self.w*2 return rect a = Geaom(50, 60) print(a.rectangle())
18th Dec 2017, 6:20 PM
Ankit Agrawal
Ankit Agrawal - avatar