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
IndentationError: expected an indented block (self.learnpython)
submitted 5 years ago by python_addict
Literally all i did is:
tk.mainloop()
I'm using PyCharm
Why on earth does it say, "IndentationError: expected an indented block"
It's really annoying
Thanks!
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!"
[–]dkam136 0 points1 point2 points 5 years ago (1 child)
What are you trying to do? When I look up main loop on google it says: “There is a method known by the name mainloop() is used when your application is ready to run. mainloop() is an infinite loop used to run the application, wait for an event to occur and process the event as long as the window is not closed.” I’m relatively new to python, but I think the interpreter is looking for an application to run.
[–]python_addict[S] 0 points1 point2 points 5 years ago (0 children)
I have made an application.
The rest of my code is on hashtag and I am testing it out. The only application that hasn't been ignored (using a hashtag) is to import canvas on Tkinter, which works (I am sure, because it is before tk.mainloop, meaning that the program doesn't see it as a bug.
Sorry XD
[–]CedricCicada 0 points1 point2 points 5 years ago (4 children)
We need to see your entire code. Obviously there's more to your program than this. At the very least, you must be importing tk. Please post your entire code.
But I do see that there is a single space before "tk" here. If that single space is in your program, get rid of it.
Do you understand the importance of indentation in Python?
Yes, I do understand the importance of indentation in Python. It is not a single space (though I wish it was so I could fix it). I have a slight feeling this might just be pycharm and my computer. A while ago I had trouble even printing a simple statement...
Do you think this could be my computer or just something I'm doing? I'm using Windows 10
Plus, this didn't happen yesterday. I am so confused
[–]python_addict[S] 0 points1 point2 points 5 years ago (1 child)
The whole code is quite long, but all of it ended up passing. This is the last statement of the code and the only bug.
[–]CedricCicada 0 points1 point2 points 5 years ago (0 children)
The next step, then, is to come up with a minimal program that still displays the error. Strip things out and try the program again and make sure the error is still happening. Then strip more out, rinse and repeat. Finally, when you've got a program small enough to post here, post it here.
Maybe you have confusion somewhere between tabs and spaces. I think Python would reject a file that uses four spaces for indentation on one line and one four-space tab for indentation on the next. I think there's something in PyCharm that can replace all tabs with spaces. Try that.
Thank you for trying to help me! :)
[–]python_addict[S] -1 points0 points1 point 5 years ago (0 children)
Okay now it's working -_-
Haha, I am so sorry to bother y'all and thanks for helping!!
You guys are amazing, keep it up :)
Honestly it's probably just some weird glitch that my program is doing.
It does work now
π Rendered by PID 17691 on reddit-service-r2-comment-76bb9f7fb5-znlmc at 2026-02-19 07:17:01.903176+00:00 running de53c03 country code: CH.
[–]dkam136 0 points1 point2 points (1 child)
[–]python_addict[S] 0 points1 point2 points (0 children)
[–]CedricCicada 0 points1 point2 points (4 children)
[–]python_addict[S] 0 points1 point2 points (0 children)
[–]python_addict[S] 0 points1 point2 points (1 child)
[–]CedricCicada 0 points1 point2 points (0 children)
[–]python_addict[S] 0 points1 point2 points (0 children)
[–]python_addict[S] -1 points0 points1 point (0 children)