how to make function in __init__ in python code example

Example 1: __init__ python

class Person:
  def __init__(self, name, age):
    self.name = name
    self.age = age

p1 = Person("John", 36) // Object definition

print(p1.name)
print(p1.age)

Example 2: init in python

class Employee():
    no_of_leaves = 8

    def __init__(self, aname, asalary, arole):
        self.name = aname
        self.salary = asalary
        self.role = arole

    def printdetail(self):
        return f"Name is {self.name}. His salary is {self.salary}." \
               f"and his role is {self.role}"