Python - Constructors and Object Initialization
What is wrong with this __init__ method?
class Book:
def __init__(title, author):
self.title = title
self.author = authorWhat is wrong with this __init__ method?
class Book:
def __init__(title, author):
self.title = title
self.author = author__init__ must be self to refer to the instance.self is missing, so title is treated as self, causing errors.self parameter is missing as the first argument. -> Option B__init__ always needs self first [OK]self must be first parameter in __init__ [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions