(The occam programming language also used it.) However, ABC’s authors did invent the use of the colon that separates the lead-in clause from the indented block. Python’s use of indentation comes directly from ABC, but this idea didn’t originate with ABC-it had already been promoted by Donald Knuth and was a well-known concept of programming style. This is different from many other languages that use curly braces is outlined in an article of the history of Python by Guido van Rossum - the creator of Python: In Python, indentation is used to delimit blocks of code. See How to fix Python indentation for more tools and techniques to clean up indentation to conform to standards (even if it already "works"). See Else clause on Python while statement if you need to close questions where OP did that. One common form of this is attaching else: to a for or while loop rather than (as intended) the corresponding if. It's also possible to have logically incorrect indentation that does not cause an error message. This is not a duplicate of existing questions about unindents or unexpected indents because they only deal with one type of indentation error each, and I'm looking to cover them all in one place. Note: This is an attempt at a canonical question because I see many similar posts every month. What do these errors mean? What am I doing wrong? How can I fix my code?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |