Need help to correct my code in python

Hi, Im trying to run my magic 8 ball generator app, but it is saying “NameError: name ‘self’ is not defined” In python

Please tell me the issue thx.

You are using self outside of the Form’s class, that’s the issue. :slight_smile:

In python the indentation level is important.

The last block of lines is not indented, so it’s executed only once, when the module is imported.

If you indent it 4 spaces, it will belong to __init__ and will be executed every time the form is created, and self will refer to the form being created.

2 Likes