-1

during the run time I received an indentation error in init function I tried to solve it by moving the error line trying to fix it.

class Category:
 """
 Creates category class, possible child class of products
 Parameters
­­­­­­­­­­
 name : str, default blank
 Desired name of category
 category_type : str, default blank
 type of category
 model : int , default 0 
 model of category in years
 """
#Declaring __init__()Function
def __init__(self,name="",category_type="",model=0):
        """
           Constructs all the necessary attributes for the category object.
         Parameters
         ----------
            name : str
                 name of the category
            category_type : str
                category type of the category
            model : int
                year of the category
        """
     self.name = name
     self.category_type = category_type
     self.model = model
     print (name,"Created!") # Run when init is finished.
#Declaring print_status()Function
 def print_status(self):
  print("Category :{0}\n category type :{1}\n Model :{2}".format(self.name,self.category_type,self.model))

p1 = Category("Iphone","Technology",2020)
p1.print_status()

The error message : File "", line 26 self.name = name ^ IndentationError: unindent does not match any outer indentation level

Faisal
  • 13
  • 1

1 Answers1

0

Is the Docstring!

def __init__(self,name="",category_type="",model=0):
    """
        Constructs all the necessary attributes for the category object.
        Parameters
        ----------
        name : str
        name of the category
        category_type : str
        category type of the category
        model : int
        year of the category
    """
    self.name = name
    self.category_type = category_type
    self.model = model
    print (name,"Created!") # Run when init is finished.
    #Declaring print_status()Function
    def print_status(self):
    print("Category :{0}\n category type :{1}\n Model :{2}".format(self.name,self.category_type,self.model))
Federico Baù
  • 6,013
  • 5
  • 30
  • 38