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

Source: Internet
Author: User
Tags python script
Indentationerror:unindent does not match any outer indentation level appears in Python

Copy a piece of code today on-line. The code is very easy and each line looks indented. An error such as the following occurred when executing:

"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 seems to be no problem, there are indentation. And there's no mistake in grammar.

2. Careful study of the code, found that really do not see what the problem. It occurred to me that all the characters of the current Python script (including spaces and tab characters) were displayed to see if there were any indents or other special characters.

The currently used text editor notepad++, has a setting that can display all the characters.
In:
View –> display symbols –> display spaces and tabs
This will allow us to see whether any of our Python code is indented.

Finally found that the reason for the code error is really here, the wrong hint of this line appears to be indented. Indeed, there is no indentation, and that is the root of the problem.

Found a problem. There is no indentation in the Python code that was found in copy, and when we copy someone else's code, the indentation 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 error 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.