I'm able to calculate area of square without using class/method but when I want to add it to the class if it is failing on line 8 with the following error:
area() takes 1 positional argument but 2 were given
My code try is:
class Square():
def area(side_length):
calc = side_length**2
return calc
figure = Square()
side_length = int(input("Enter side length: "))
print(figure.area(side_length))
If I run this code, it works fine. I think I'm doing smth wrong in calling methods:
def area(side_length):
calc = side_length**2
return calc
side_length = int(input("Enter side length: "))
area(side_length)