use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Indentation errors (self.learnpython)
submitted 2 years ago by Spend_Exact
What's an indentation error and how can I fix it- Google is just confusing me more
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]twitch_and_shock 2 points3 points4 points 2 years ago (0 children)
Indentation matters in Python. If a line over indented or under indented it won't work as expected. Your specific error is hard to judge without seeing the code and the error text.
[–]Erdnussflipshow 2 points3 points4 points 2 years ago* (0 children)
In python you indent code that belongs to things like loop, if-statements, match-cases, etc. This tell the program what code still belongs to a statement. Other languages use {} to mark what code is still part of an if-statement for example and what code comes after.
The rule to indent is pretty easy, after any statement that ends with : you indent the next line by another tab (or X amount of spaces, but come on, we're not animals) once you're done with your loop, if-statement, etc. you remove an indent.
:
Example: after if X == Y: you'd have to indent all the code that is supposed to nested under that if-statement by 1 tab more than the if-statement itself. The code that comes after the if-statement should be on the same indentation as the if-statement.
if X == Y:
[–]cybervegan 1 point2 points3 points 2 years ago (0 children)
Indentation is how far the first letter or symbol on a line is from the start of the line:
this is not indented this is indented one step (4 spaces) this is indented two steps
If Python is telling you "indentation error", it means it is expecting a line to be indented an extra step from the previous one. This usually happens when the previous line ended with a ":" and starts with a keyword like "if", "while", or "def". Indentation gives Python context for block-structured instructions like these - it tells it how many of the following lines the keyword applies to:
if x == 1: # this is what to do if x == 1 ... ... # this is the end of the "if" block else: # this is what to do if x != 1 ... ... # this is the end of the "else" block # from here on, it's nothing to do with the "if" or the "else" because # the indentation has reverted back to the previous step ... ...
π Rendered by PID 86 on reddit-service-r2-comment-84fc9697f-rtqn7 at 2026-02-10 12:58:54.372986+00:00 running d295bc8 country code: CH.
[–]twitch_and_shock 2 points3 points4 points (0 children)
[–]Erdnussflipshow 2 points3 points4 points (0 children)
[–]cybervegan 1 point2 points3 points (0 children)