Brandon-Lee Brown
Brandon-Lee Brown

Reputation: 3

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

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.

Upvotes: 0

Views: 375

Answers (2)

storageSpaceFull
storageSpaceFull

Reputation: 127

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.

Upvotes: 0

ilyasbbu
ilyasbbu

Reputation: 1749

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

So add a statement in there, example:

class Animal():
    pass

Upvotes: 2

Related Questions