I main java and just started on python, and I ran into this error when I was trying to create a class. Can anyone tell me what is wrong?
import rectangle
a = rectangle(4, 5)
print(a.getArea())
this is what is in the rectangle class:
class rectangle:
l = 0
w = 0
def __init__(self, l, w):
self.l = l
self.w = w
def getArea(self):
return self.l * self.w
def getLength(self):
return self.l
def getWidth(self):
return self.w
def __str__(self):
return "this is a", self.l, "by", self.w, "rectangle with an area of", self.getArea()
rectangle.rectangle(4,5)