Posted inPython

python indentation error – How To Avoid Indentation Error In Python?

python indentation error – The indentation error can occur when the spaces or tabs are not placed properly. Base class of IndentationError is SyntaxError.

python indentation error – How do i resolve the unexpected indent error in python?

Indentationerror error is always because of tab and white space mixed in your python code. We generally use 4 white spaces to present indentation in python.

Python Indentation Error

You are mixing tabs and spaces.

//Find the exact location with:

python -tt yourscript.py

How Does Python Indentation work?

def getData():
    print("Welcome")
 
    if True:
        print("true")
    else:
        print("false")
 
print("Done")

IndentationError Examples

>>>     x = 50
  File "", line 1
    x = 50
    ^
IndentationError: unexpected indent
>>> 

code example:

 name = "Dr. Rajdeep" 
      if len(name) > 0: 
          results = 'Yay! Dr is not available' 
          print results 

Don’t Miss : Importerror: No Module Named Request

I hope you get an idea about python indentation error.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype