Python Question 1: IndentationError: expected an indented block, expectedanindented

Source: Internet
Author: User

Python Question 1: IndentationError: expected an indented block, expectedanindented

The Python language is a language that is very sensitive to indentation and brings confusion to many beginners. Even experienced python programmers may fall into a trap. The most common case is that the combination of tabs and spaces may cause errors or indentions, which cannot be separated by the naked eye.

This error occurs during compilation.IndentationError: expected an indented blockIt indicates that indentation is required here. You only need to indent the line with spaces or tabs (but cannot be mixed) When an error occurs.

Some people may wonder: why is it wrong if I don't indent at all? If I don't indent it, I have to indent it. If I don't indent it, it will lead to errors. For example:

If xxxxxx:

(Space) xxxxx

Or

Def xxxxxx:

(Space) xxxxx

And

For xxxxxx:

(Space) xxxxx

The next line with a colon always needs to be indented.

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.