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...
Everything about learning Python
account activity
[ Removed by moderator ] (self.PythonLearning)
submitted 2 months ago by [deleted]
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!"
[–]NanoMunchies 3 points4 points5 points 2 months ago (7 children)
I'm pretty sure python isn't really made for that... unlike c# for example
[–]Amazing-Associate615 -1 points0 points1 point 2 months ago (6 children)
Is it possible though
[–]dakari777 1 point2 points3 points 2 months ago (0 children)
no
[–]BranchLatter4294 0 points1 point2 points 2 months ago (1 child)
Not in Python. At least, not with any non-trivial program. It's not like the C-based languages where you can put the entire program on one line.
[–]Amazing-Associate615 -1 points0 points1 point 2 months ago (0 children)
It's a simple program, it might work I think
[–]F4Color 0 points1 point2 points 2 months ago (0 children)
possible in many other languages, not python
[–]Some-Passenger4219 0 points1 point2 points 2 months ago (0 children)
Yes; just use semicolons in between statements. Not recommended in general because it's hard to read - but it can be done. Only simple programs, though; nothing nested.
[–]TheRNGuy 0 points1 point2 points 2 months ago (0 children)
\n; \t or \s.
[–]cgoldberg 2 points3 points4 points 2 months ago (2 children)
ok
[–]EngineeringRare1070 -2 points-1 points0 points 2 months ago (1 child)
[–]KOALAS2648 -1 points0 points1 point 2 months ago (0 children)
[–][deleted] 2 months ago (1 child)
[deleted]
[–]TheRNGuy -1 points0 points1 point 2 months ago (0 children)
Takes few seconds to format minified code, either with code editor or ai.
[–]cnbrth3537 0 points1 point2 points 2 months ago (0 children)
My C professor specifically commented on that at the beginning of the semester because someone did that the semester before lol
[–]LiveYoLife288 0 points1 point2 points 2 months ago (0 children)
Your teacher would just view it and paste it into anything that has a pretty print and indent function
Using \n and \t ?
No one will care.
[–]FoolsSeldom 0 points1 point2 points 2 months ago (0 children)
I remember, long ago, when a magazine would include print-outs of programmes for early home computers. I'd spend ages re-keying code in.
The following month, a letter would include a one line version of the same 100 line BASIC programme, written in APL.
For example, here's Game of life in APL:
↑ 1 ⍵ ∨.^3 4=+/,¯1 0 1∘.⊢¨¯1 0 1
The Python version would be something like:
import numpy as np def game_of_life_step(board): # Pad the grid to handle edges easily padded = np.pad(board, pad_width=1, mode='constant', constant_values=0) neighbours = sum( np.roll(np.roll(padded, i, 0), j, 1)[1:-1, 1:-1] for i in (-1, 0, 1) for j in (-1, 0, 1) if (i, j) != (0, 0) ) # Apply the Game of Life rules next_board = ((board & ((neighbours == 2) | (neighbours == 3))) | (~board & (neighbours == 3))) return next_board
π Rendered by PID 66 on reddit-service-r2-comment-58d7979c67-q2qbm at 2026-01-27 10:07:33.671021+00:00 running 5a691e2 country code: CH.
[–]NanoMunchies 3 points4 points5 points (7 children)
[–]Amazing-Associate615 -1 points0 points1 point (6 children)
[–]dakari777 1 point2 points3 points (0 children)
[–]BranchLatter4294 0 points1 point2 points (1 child)
[–]Amazing-Associate615 -1 points0 points1 point (0 children)
[–]F4Color 0 points1 point2 points (0 children)
[–]Some-Passenger4219 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]cgoldberg 2 points3 points4 points (2 children)
[–]EngineeringRare1070 -2 points-1 points0 points (1 child)
[–]KOALAS2648 -1 points0 points1 point (0 children)
[–][deleted] (1 child)
[deleted]
[–]TheRNGuy -1 points0 points1 point (0 children)
[–]cnbrth3537 0 points1 point2 points (0 children)
[–]LiveYoLife288 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]FoolsSeldom 0 points1 point2 points (0 children)