IndentationError: expected an indented block after class definition on line

IndentationError: expected an indented block after class definition on line

In python IndentationError: expected an indented block after class definition on line we face this error message when we create a class and not indented inside a class or do not use the pass keyword then the python interpreter shows this error message, If you want to fix this error you need to just use pass inside a class or need to indented you next line code, For more clarification see the below example.

Wrong Code

class User:
     

user_1 = User()
user_1.id = "001"
user_1.username = "Amol"

print(user_1.username)

Error Massage

  File "/home/kali/python/webproject/quiz/17day/main.py", line 4
    user_1 = User()
    ^
IndentationError: expected an indented block after class definition on line 1

Wrong code line

class User:
     

Correct code line

class User:
    pass
  • Wrong action: Outside or incorrect indentation.
  • Correct action: In-site with use pass.

Entire Correct Code line

class User:
    pass
     

user_1 = User()
user_1.id = "001"
user_1.username = "Amol"

print(user_1.username)

What is IndentationError: expected an indented block after class definition on line?

In python, we face this error message when we create a class and are not indented inside a class or do not use the pass keyword then the python interpreter shows this error message.

How to fix IndentationError: expected an indented block after class definition on line?

If you want to fix this error you need to just use pass inside a class or need to indent your next line code, For more clarification see the above example.

For more information Visit YouTube Channel.

Scroll to Top
Top 7 Gaming Project In python Save ₹25,000 Laptop under ₹11,999 Top 7 Funny error in Python Unicodeescape Most dangerous error in Python Hero Electric Battery Price In 2023