Skip to content
Advertisement

Can’t define class in python [closed]

CODE::

JavaScript

Error::

Traceback (most recent call last): File “C:/Users/Jedi/PycharmProjects/LMS/main.py”, line 5, in class Library: File “C:/Users/Jedi/PycharmProjects/LMS/main.py”, line 62, in Library application = Library(root) NameError: name ‘Library’ is not defined

Process finished with exit code 1

Advertisement

Answer

Firstly, your indentation is wrong, you have to place the if on the same indentation level as class, like:

JavaScript

Secondly, but most importantly, your def __init_() has a typo, it should be __init__() with two underscore trailing and leading init, but you gave just one(trailing).

JavaScript

But even after doing all this, you will get another error at Title_Frame.grid(side=TOP), because grid() has not option side, it is the option of pack(), so change that to:

JavaScript
Advertisement