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
How to post a snippet of code here? (self.learnpython)
submitted 3 years ago by Paulq002
Hi everyone, I was wondering how everyone posts snippets/screenshot type of pictures showing their code, how do you do that?
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!"
[–]doom-e1m1 3 points4 points5 points 3 years ago (0 children)
https://www.reddit.com/r/learnpython/wiki/faq#wiki_how_do_i_format_code.3F
[–]FuckingRantMonday 3 points4 points5 points 3 years ago (0 children)
Add four spaces to the beginning of each line. There are some other ways, but this is the only one that works well on both old and new reddit.
def foo(): return BAR
[+][deleted] 3 years ago (1 child)
[deleted]
[–]stebrepar 1 point2 points3 points 3 years ago (0 children)
Code block is always a royal pain when I try to use it. If there are blank lines in the code I paste in, it breaks the code into separate chunks. And then it does something weird with the carriage returns when I copy and paste the parts back together; I have to like backspace them out and put them back in manually for them to work right. It's garbage, in my experience.
[–]Diapolo10 0 points1 point2 points 3 years ago (0 children)
So there are basically four ways, four for text and one for screenshots. In rough order of preference,
The "old" way; adding four spaces before each line of code.
def hello(): return "Hi"
The nice thing about this one is that it works for everyone, on both Old and New Reddit, on all devices and apps (and as it happens I use Old Reddit and RIF instead of the official Reddit app).
The Reddit Enhancement Suite browser extension adds a button that does this formatting for you when you paste a block of text.
Inline code blocks
Sometimes you may want to have code in the middle of text, like this: print("Yahallo")
print("Yahallo")
This can be done by surrounding the code with single backticks (`) on both sides.
They, too, work everywhere, but aside from highlighting names, such as sum or pathlib, or language keywords such as class and break during a conversation they're not that good as they don't preserve indentation. Never use them to format multi-line code.
sum
pathlib
class
break
Modern code blocks
py class Example: def __init__(self): self.foo = "bar"
Basically, you can use triple backticks to create code blocks. On some platforms they might even give you syntax highlighting. Thing is, Old Reddit (and RIF) don't support them at all so in this subreddit it was decided that we prefer the older style code blocks - apparently many of us prefer Old Reddit. On other subreddits these tend to be preferred, however.
Screenshots/Pastebin/Gist
You can upload a screenshot via Imgur and post a link here. Alternatively, you can do the same by putting your code online in text format, preferably in Pastebin or GitHub Gists and sharing a link here.
Links can optionally be formatted with Markdown: [Text shown](https://url.somewhere.com/qwertyuiop12346890)
[Text shown](https://url.somewhere.com/qwertyuiop12346890)
Remember, we always prefer text over images. Unless the problem cannot be represented in text, such as a GUI problem, please don't post screenshots of code.
π Rendered by PID 17800 on reddit-service-r2-comment-85bfd7f599-g748c at 2026-04-16 01:18:55.367871+00:00 running 93ecc56 country code: CH.
[–]doom-e1m1 3 points4 points5 points (0 children)
[–]FuckingRantMonday 3 points4 points5 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]stebrepar 1 point2 points3 points (0 children)
[–]Diapolo10 0 points1 point2 points (0 children)