I'm not an expert in Python and I'm not getting this to work. It is for a coding challenge to enter a new course, let's say 'academic purpose'
class ClaseVehiculo:
def __init__(self,tipo,color):
self.tipo = tipo
self.color = color
self.velocidad = 0
if not ( tipo in ['auto','camioneta','moto']) :
print ( 'Tipo de vehiculo no reconocido. No se puede crear la clase: ClaseVehiculo.' )
CANCEL
@classmethod
def Acelerar(self,variacion):
self.velocidad += variacion
if self.velocidad < 0:
self.velocidad = 0
if self.velocidad > 100:
self.velocidad = 100
return ClaseVehiculo
a = ClaseVehiculo('auto','verde')
print ( a )
print ( a.tipo() )
Apparently, 'a' is initialized as a ClaseVehiculo class but
when Print (a.tipo() ) 'tipo' is not recognized as a class attribute