- 1
Rectangle does not have attributes newsquare. please fix the code
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def calculate_area(self): return self.width * self.height @classmethod def new_square (cls, side_length): return cls(side_length, side_length) square = Rectangle.newSquare(5) print(square.calculate_area())
2 Answers
+ 4
You should recheck your code before asking us to correct it .
Ok , what is newSquare in "Rectangle.newSquare(5)" ??
Shudn't it be Rectangle.new_square(5)
+ 3
naw, just change the second to last line. should be:
square = Rectangle.new_square(5)