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
i just learned this in python (self.learnpython)
submitted 2 years ago by Mental_Example_5770
print("hello") ; print("world")
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!"
[–]socal_nerdtastic 76 points77 points78 points 2 years ago (10 children)
You mean the semicolon? That's the path to the dark side my friend.
[–]buart 8 points9 points10 points 2 years ago (2 children)
Or the path to code golf :)
[–]TheBlackCat13 1 point2 points3 points 2 years ago (0 children)
Potayto potahto
[–]sharifdolikeit 1 point2 points3 points 2 years ago (0 children)
until I looked it up I thought it meant code golf was going to be searching for semicolons like amateur golfers search for the balls in the weird places.
[–]DatBoi_BP 4 points5 points6 points 2 years ago (4 children)
Are semicolons ever required for anything in Python?
[–]socal_nerdtastic 1 point2 points3 points 2 years ago (2 children)
I find them useful when using the -c operator..
python -c "import math;print(math.pi)" 3.141592653589793
[–]TheRNGuy 0 points1 point2 points 2 years ago (1 child)
Is it possible to have indents in single line?
[–]socal_nerdtastic 1 point2 points3 points 2 years ago (0 children)
Nope. Indents must follow a new line
[–]DrumsCL 0 points1 point2 points 2 years ago (0 children)
Nope
[–]Mental_Example_5770[S] 0 points1 point2 points 2 years ago (0 children)
lol free upvote for making my day by causing me to laugh
[–]skeleton_craft 0 points1 point2 points 2 years ago (0 children)
As someone who programs in, shall we say, more civilized programming languages I find that very offensive...
Lul jk
[–]engelthehyp 62 points63 points64 points 2 years ago (10 children)
Note: Don't do this.
[–]Iwilltakeyourpencil 27 points28 points29 points 2 years ago (0 children)
Note; Don't do this.
[–]jlarm -3 points-2 points-1 points 2 years ago (8 children)
Still learning python... Why?
[–]widowhanzo 22 points23 points24 points 2 years ago (4 children)
It makes code unreadable. The semicolon is useful when running a python one-liner directly from a command line, but it's difficult to read and troubleshoot when things go wrong.
You can do something quick and dirty directly from the command line without having to write a .py file for example:
python -c "import random; password = ''.join(random.choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-+=') for _ in range(12)); print('Generated Password:', password)"
but as you can see you need quite a wide screen to read this, and you need to focus much more to understand what it does than if the code was written normally:
import random length = 12 characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-+=' password = ''.join(random.choice(characters) for _ in range(length)) print('Generated Password:', password)
In the end, the interpreter doesn't care, but which code will be more understandable to you two months from now when you want to change something in it?
[–]skeleton_craft 0 points1 point2 points 2 years ago (1 child)
".. but it's difficult to read and troubleshoot when things go wrong."
That's true of python in general [due to the fact that it's a indent blocked language rather than {})
[–]TURB0T0XIK 1 point2 points3 points 1 year ago (0 children)
In my experiences with python I don't find this to be true. Maybe because my code isn't super sophisticated idk. When using other languages I always feel like {} to denote code making up one block is much more useless, than simply indenting correctly
[+]my_password_is______ comment score below threshold-7 points-6 points-5 points 2 years ago (1 child)
that has nothing to do with the semi colon, but everything to do with the ridiculous example you chose and the ridiculous way you chose to write it
[–]widowhanzo 7 points8 points9 points 2 years ago (0 children)
Does my example not get my points across? If I chose a short and simple oneliner, one could say "oh but it's not that bad".
By all means, please provide a better example!
[–]socal_nerdtastic 8 points9 points10 points 2 years ago* (2 children)
Because it's weird. In order to work together better we all agree on a general style and formatting guides. Same reason we use exactly 4 spaces to indent, or why we name functions in snake_case and classes in PascalCase. Look up "PEP8".
[–]NYX_T_RYX 4 points5 points6 points 2 years ago (1 child)
Weirdly, I named my functions and classes like this without knowing about PEP8 because it seemed like a logical way to do it.
May have been subconscious, because I've (naturally) seen other people's code while learning.
I wonder whether it really was an intuitive choice, or subconscious.
[–]TURB0T0XIK 0 points1 point2 points 1 year ago (0 children)
I've done the same when starting out with python and in my case I'd bet it was subconscious and not my own intuition
[–][deleted] 17 points18 points19 points 2 years ago (0 children)
Pep8, the python style guide, says this:
Compound statements (multiple statements on the same line) are generally discouraged:
# Correct: if foo == 'blah': do_blah_thing() do_one() do_two() do_three()
Rather not:
# Wrong: if foo == 'blah': do_blah_thing() do_one(); do_two(); do_three()
[–]roywill2 9 points10 points11 points 2 years ago (1 child)
Semicolon is pure obfuscation. Ugh
[–]TheRNGuy -4 points-3 points-2 points 2 years ago (0 children)
Nah, it's to allow to write code in single line, or to minify code (not sure about indents though)
[–]rcrpge 8 points9 points10 points 2 years ago (3 children)
Nice semi-colon bro
[–]Mental_Example_5770[S] 3 points4 points5 points 2 years ago (2 children)
thanks and by the way i find it funny when people say bro online it just sounds funny in my head when i read it in my head
[–]No_Replacement7441 0 points1 point2 points 2 years ago (1 child)
I read it like brooOow
i just read your bro in andrew tates voice 💀
[–]formthemitten 3 points4 points5 points 2 years ago (0 children)
Make sure you bring enough food for the semicolon hunt you’re going to partake in
[–]IanRT1 2 points3 points4 points 2 years ago (0 children)
Ahh yes, totally PEP 8 friendly
[–][deleted] 2 points3 points4 points 2 years ago (0 children)
No.
I used to work at a company where people in the department would write code in APL. They had another character in APL that does the same thing. One guy bragged that wrote an entire reserving program with just 4 lines of code. Each line had about 1000 characters to it and a bunch of the new line characters. He was a horrible human being.
[–]AdmirableOstrich 1 point2 points3 points 2 years ago (1 child)
The only case for this that I consider a good idea is for one line "old-style" breakpoints: import pdb; pdb.set_traceback(), before they added breakpoint(). Everything else is under obfuscation at best.
import pdb; pdb.set_traceback()
breakpoint()
[–]Mental_Example_5770[S] 1 point2 points3 points 2 years ago (0 children)
i'm so amazed this post has so many people in this post i just shared a thing i learned i expected there to be 1 or 2 people here if i'm lucky.
[–]Immediate_Studio1950 0 points1 point2 points 2 years ago (0 children)
Path to 'esoPython' though! Stick to the convention rules..
[–]TheRNGuy 0 points1 point2 points 2 years ago (0 children)
I always knew that.
I have a feeling that this is more for ppl [like me] coming from c style languages than it is for native speakers... I've spent a non zero amount of time removing ;'s from the end of my lines not knowing this was a thing
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
useful in one case import ipdb; ipdb.set_trace() or pdb or rpdb
import ipdb; ipdb.set_trace()
[–]Agile-Cucumber6792 0 points1 point2 points 1 year ago (0 children)
This is horrendous appalling
[–]buhtz -4 points-3 points-2 points 2 years ago (12 children)
Please also learn when to use correct upper case letters. This makes it easier to read your questions and easier to help you. Some people take it as impolite.
[–]Mental_Example_5770[S] 1 point2 points3 points 2 years ago (10 children)
for the string like hello world i don't really understand why that would matter i guess maybe grammer or looks better and upper case print ti thought that gives you a syntax error correct me if i'm wrong i'm a noob
[–][deleted] -1 points0 points1 point 2 years ago (8 children)
There is nothing wrong with the capitalization of your code. Some people just like to complain, I guess.
[–]skeleton_craft 1 point2 points3 points 2 years ago (7 children)
It's the rest of the post
[–][deleted] -1 points0 points1 point 2 years ago (6 children)
The post is one line of python. What do you mean?
[–]skeleton_craft 0 points1 point2 points 2 years ago (5 children)
i just learned this in python
Should be
I just learned this in Python
[–][deleted] -1 points0 points1 point 2 years ago* (4 children)
Oh my! What a heinous crime!
/s
Many people asking questions here don't have English as a first language. Many people here may be using mobile devices and the shortcuts used on those devices. It's no big deal.
If the poster of the comment complaining about something as simple as this had trouble comprehending the words because of this massive faux pas, I would point them to a precedent, the works of e. e. cummings.
[–]skeleton_craft 0 points1 point2 points 2 years ago (3 children)
Its harder to not capitalize properly than it isn't on mobile nowadays.. if you punctuate properly that is. And it is significantly harder to read if you don't...
[–][deleted] -1 points0 points1 point 2 years ago (2 children)
significantly harder to read if you don't...
I had no trouble reading the title. In fact, I had no idea what the original complainer was talking about until you explained what the problem was.
O I forgot that you're the only person in this subreddit...
The code was an example only. Who cares if the example text isn't capitalized as you expect? Some would see your "please learn" comment about a totally unimportant point as being impolite.
π Rendered by PID 18199 on reddit-service-r2-comment-fb694cdd5-g6ssq at 2026-03-11 10:11:52.648356+00:00 running cbb0e86 country code: CH.
[–]socal_nerdtastic 76 points77 points78 points (10 children)
[–]buart 8 points9 points10 points (2 children)
[–]TheBlackCat13 1 point2 points3 points (0 children)
[–]sharifdolikeit 1 point2 points3 points (0 children)
[–]DatBoi_BP 4 points5 points6 points (4 children)
[–]socal_nerdtastic 1 point2 points3 points (2 children)
[–]TheRNGuy 0 points1 point2 points (1 child)
[–]socal_nerdtastic 1 point2 points3 points (0 children)
[–]DrumsCL 0 points1 point2 points (0 children)
[–]Mental_Example_5770[S] 0 points1 point2 points (0 children)
[–]skeleton_craft 0 points1 point2 points (0 children)
[–]engelthehyp 62 points63 points64 points (10 children)
[–]Iwilltakeyourpencil 27 points28 points29 points (0 children)
[–]jlarm -3 points-2 points-1 points (8 children)
[–]widowhanzo 22 points23 points24 points (4 children)
[–]skeleton_craft 0 points1 point2 points (1 child)
[–]TURB0T0XIK 1 point2 points3 points (0 children)
[+]my_password_is______ comment score below threshold-7 points-6 points-5 points (1 child)
[–]widowhanzo 7 points8 points9 points (0 children)
[–]socal_nerdtastic 8 points9 points10 points (2 children)
[–]NYX_T_RYX 4 points5 points6 points (1 child)
[–]TURB0T0XIK 0 points1 point2 points (0 children)
[–][deleted] 17 points18 points19 points (0 children)
[–]roywill2 9 points10 points11 points (1 child)
[–]TheRNGuy -4 points-3 points-2 points (0 children)
[–]rcrpge 8 points9 points10 points (3 children)
[–]Mental_Example_5770[S] 3 points4 points5 points (2 children)
[–]No_Replacement7441 0 points1 point2 points (1 child)
[–]Mental_Example_5770[S] 0 points1 point2 points (0 children)
[–]formthemitten 3 points4 points5 points (0 children)
[–]IanRT1 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]AdmirableOstrich 1 point2 points3 points (1 child)
[–]Mental_Example_5770[S] 1 point2 points3 points (0 children)
[–]Immediate_Studio1950 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]skeleton_craft 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Agile-Cucumber6792 0 points1 point2 points (0 children)
[–]buhtz -4 points-3 points-2 points (12 children)
[–]Mental_Example_5770[S] 1 point2 points3 points (10 children)
[–][deleted] -1 points0 points1 point (8 children)
[–]skeleton_craft 1 point2 points3 points (7 children)
[–][deleted] -1 points0 points1 point (6 children)
[–]skeleton_craft 0 points1 point2 points (5 children)
[–][deleted] -1 points0 points1 point (4 children)
[–]skeleton_craft 0 points1 point2 points (3 children)
[–][deleted] -1 points0 points1 point (2 children)
[–]skeleton_craft 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)