Why isn’t my code working??? It keeps crashing with this error “area not defined” | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why isn’t my code working??? It keeps crashing with this error “area not defined”

class Class: def __init__(self, width, height, bool): self.width=width self.height=height self.bool=bool def area(): print("Running") return self.width * self.height def calc(self): if self.bool == True: print("Running") area() else: print("Stopped") @classmethod def sub(cls, length, val): return cls(length, length, val) square = Class.sub(5, True) print(square.calc())

12th Mar 2022, 12:56 PM
Anorue Smith
Anorue Smith - avatar
1 Answer
+ 1
Ravilnicki, Thanks. It stopped the error message🤩🥳👍🏽 But now it out puts “None”😭😭 Instead of 25
12th Mar 2022, 2:34 PM
Anorue Smith
Anorue Smith - avatar