Getting an attribute error when working with function in Python -
i browsed through several similar questions on here before decided ask. there similar questions same error, weren't same type of problem, , none of answers resolved problem.
nonetheless, i'm getting typeerror says 'function' object has no attribute 'getitem'. here code:
def rectangle(width, height): area = rectangle[width] * rectangle[height] = rectangle(5, 7) print(a.area)
now know there easier ways this, challenge using functions , classes. i'm wondering i'm going wrong this?
you need create class
. i'll started:
class rectangle: def __init__(self, width, height): self.width = width self.height = height @property def area(self): homecoming self.width * self.height
what have function. seeing each instance of object should have it's own attributes, need create type store them.
python function class
No comments:
Post a Comment