- 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))
2 odpowiedzi
+ 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
+ 1
Thank you Slick!