Indentationerror:unindent does not match any outer indentation level appears in Python

Source: Internet
Author: User
Tags python script

Indentationerror:unindent does not match any outer indentation level appears in Python

Today on the online copy of a piece of code, the code is very simple, each line seems to indent the indentation, the operation of the following error occurred:

"Resolution Process"
1. The most common reason for this error is that it does not indent. According to the number of error prompts, go to the code to see, there is no problem, there are indentation, and the syntax is not wrong.

2. Careful study of the code, found that there is really no problem, it occurred to me that all the characters of the current Python script (including spaces and tab characters) are displayed to see if there is any indentation or other special characters.

Currently with the text editor notepad++, there is a setting that can display all the characters.
In:
View –> display symbols –> display spaces and tabs
This allows us to see whether the indentation of our Python code is indented in the end.

Finally found that the code is the reason for the error is here, the wrong hint of the line appears to be indented, and actually do not indent, this is the source of the problem.

Found a problem, found that copy of the Python code is not indented, when we copy someone else's code, indentation this requires extra attention. Don't look like the code is indented and it feels OK, actually it's not indented.



Indentationerror:unindent does not match any outer indentation level appears in Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.