Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


8,090 questions

11,268 answers

573 users

How to add and use __init__ method in a class in Python

1 Answer

0 votes
class Test:
    def __init__(self, language=None):
        self.language = language

    def method(self):
        if self.language:
            print(self.language)
        else:
            print("Language is empty")

o1 = Test()
o1.method()

o2 = Test("Python")
o2.method()


'''
run:
 
Language is empty
Python
 
'''

 




answered Feb 8 by avibootz
...