Python Tutorial for Beginners

__init__() Function in Python

What Does The __init__() Function Do in Python?

To comprehend the concept of classes, we must first comprehend the built-in __init__() method.

Every class has a procedure called __init__() that is invoked every time the class is started.
To set values to object attributes or do other activities while the object is being constructed, use the __init__() function:

Code:

class Person1:

  def __init__():

    print(“python”)

p = Person1()

Output:

python
Did you find this article helpful?