Home > database >  How do I fix indentation error when creating a class in Python?
How do I fix indentation error when creating a class in Python?

Time:11-23

Every time I try to create a class, it gives me the IndentationError when I haven't even added indentations yet.

Error Screenshot

I have tried restarting Jupyter and my PC and there is no luck. I have also tried using another notebook but still face the error.

CodePudding user response:

As the error shows, it is expecting an indented block after the class.

So add a statement in there, example:

class Animal():
    pass

CodePudding user response:

You should understand the basics of classes in python for this. It is working fine, the only thing is that your code is incomplete. After you declare a class, it is simply expecting a class body.

  • Related