I am new to Python , so this might be a stupid question. I wrote this :
Class A:
def _init_(self):
self.var1 = 2
def update(self):
self.var1 = 3
But constantly getting the error in PyCharm : instance attribute var1 is defined outside init. Why?
The reason you are getting the error is due to typo error. Please replace '_' with double underscore while writing init() and similar functions. Correct code is as follows :