Invalid syntax line 6 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Invalid syntax line 6

It also says Shape has no area member Can someone clarfy where my code has gone wrong? #your code goes here class Shape: def __init__(self, w, h): self.w = w self.h = h def area(w * h): return w * h @staticmethod def calculate_area(self): return self.w * self.h w = int(input()) h = int(input()) print(Shape.area(w, h))

7th Jun 2021, 1:36 PM
Lee 4 Code
Lee 4 Code - avatar
2 Answers
+ 5
static methods dont have the "self" parameter. its more just like a regular function within a class that doesn't reference the class. its useful if you want this class to preform operations on raw data instead of having to use class attributes and it would be: print(Shape(w,h).area()) Lee For Code look at this here: https://code.sololearn.com/c7Agq2jIXqy6/?ref=app
7th Jun 2021, 1:58 PM
Slick
Slick - avatar
+ 1
Thank you Slick!
7th Jun 2021, 2:18 PM
Lee 4 Code
Lee 4 Code - avatar