{"id":1115,"date":"2023-01-05T12:22:39","date_gmt":"2023-01-05T11:22:39","guid":{"rendered":"http:\/\/heppg.de\/ikg\/wordpress\/?p=1115"},"modified":"2023-01-05T12:22:39","modified_gmt":"2023-01-05T11:22:39","slug":"indendation-problems-in-python","status":"publish","type":"post","link":"https:\/\/heppg.de\/ikg\/wordpress\/?p=1115","title":{"rendered":"Indendation problems in python"},"content":{"rendered":"\n<p>Indentation is a part of code structure in python.<\/p>\n\n\n\n<p>Indentation problems cause error messages like<\/p>\n\n\n\n<p class=\"has-luminous-vivid-orange-color has-text-color\"><code>IndentationError: unindent does not match any outer indentation level<\/code><br>IndentationError: expected an indented block after &#8216;for&#8217; statement on line 3<\/p>\n\n\n\n<p><br>There are many, really many tutorials in the web about this topic.<br><a href=\"https:\/\/python.land\/python-tutorial#Pythons_major_features\">https:\/\/python.land\/python-tutorial#Pyt &#8230; r_features<\/a><br><a href=\"https:\/\/peps.python.org\/pep-0008\/#indentation\">https:\/\/peps.python.org\/pep-0008\/#indentation<\/a><br><a href=\"https:\/\/www.w3schools.com\/python\/gloss_python_indentation.asp\">https:\/\/www.w3schools.com\/python\/gloss_ &#8230; tation.asp<\/a><br><br>Usual problems are:<br>&#8211; various deep levels, e.g. 3 blank or 4 blank deep mixed (use 4 blanks)<br>&#8211; mix of blanks and tabs for indentation.<br><\/p>\n\n\n\n<p>Thonny is a common IDE, editor for beginners. See <a rel=\"noreferrer noopener\" href=\"https:\/\/thonny.org\/\" target=\"_blank\">https:\/\/thonny.org\/<\/a><br>Too see the difference between tabs and blanks, it is good to have &#8216;highlight tab characters&#8217; enabled in the options.<\/p>\n\n\n\n<p> <img decoding=\"async\" src=\"https:\/\/forums.raspberrypi.com\/download\/file.php?id=58445\" alt=\"thonny_options.PNG\"> <\/p>\n\n\n\n<p>Then in the thonny editor, tabs are displayed in a special color. Usually a good idea to replace tabs by blanks. <\/p>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/forums.raspberrypi.com\/download\/file.php?id=58446\" alt=\"thonny_tab.PNG\"> <\/p>\n\n\n\n<p>The sample shows two tab in second line.<\/p>\n\n\n\n<p>There are text editor around which allow better visibility of all these invisible characters in a text. Here an example of a blank followed by a tab in second line.<\/p>\n\n\n\n<p> <img decoding=\"async\" src=\"https:\/\/forums.raspberrypi.com\/download\/file.php?id=58447\" alt=\"editor_show_all_characters.PNG\"> <\/p>\n\n\n\n<p>This is from &#8220;Notepad++&#8221;; good to have such a tool in the toolbox to fix stubborn problems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Indentation is a part of code structure in python. Indentation problems cause error messages like IndentationError: unindent does not match any outer indentation levelIndentationError: expected an indented block after &#8216;for&#8217; statement on line 3 There are many, really many tutorials in the web about this topic.https:\/\/python.land\/python-tutorial#Pyt &#8230; r_featureshttps:\/\/peps.python.org\/pep-0008\/#indentationhttps:\/\/www.w3schools.com\/python\/gloss_ &#8230; tation.asp Usual problems are:&#8211; various deep [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1115","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1115"}],"version-history":[{"count":1,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1115\/revisions"}],"predecessor-version":[{"id":1116,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1115\/revisions\/1116"}],"wp:attachment":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}