I am trying to create the Figure class with its respective functions but it tells me that Figure is not defined. What is the mistake?
class Figura:
def __init__(self):
self._lados = None
def main():
triangulo = Figura()
cuadrado = Figura()
cuadrado._lados = 4
triangulo._lados = 3
print(f"El triángulo tiene {triangulo._lados} lados.")
print(f"El cuadrado tiene {cuadrado._lados} lados.")
if __name__ == '__main__':
main()
ERROR => NameError: name 'Figure' is not defined
Your program is wrongly indented.
The function
main()
is not part ofclass Figura:
, so it must be peered from the left margin.