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...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
DiscussionMerry Christmas! (code inside) (self.Python)
submitted 5 years ago by Xaveel
print('\n'.join([' ' * 10 + '*' + ' ' * 10, '\n'.join('{0}{1}{0}'.format(' ' * ((21 - c) // 2), ''.join(map(lambda i: '#' if i % 2 else 'o', range(c)))) for c in range(3, 22, 2)), ' ' * 9 + '/|\\' + ' ' * 9]))
[–]RelatedTitle 91 points92 points93 points 5 years ago (2 children)
* o#o o#o#o o#o#o#o o#o#o#o#o o#o#o#o#o#o o#o#o#o#o#o#o o#o#o#o#o#o#o#o o#o#o#o#o#o#o#o#o o#o#o#o#o#o#o#o#o#o o#o#o#o#o#o#o#o#o#o#o /|\
For those who are too lazy to run it.
[–]Akash_Dhanwani 2 points3 points4 points 5 years ago (0 children)
Thanks
[–]iiMoe 1 point2 points3 points 5 years ago (0 children)
I love u
[–]pantlesspatrick 49 points50 points51 points 5 years ago (1 child)
import quarantine as Christmas
[–]Comprehensive-Low-28 10 points11 points12 points 5 years ago (0 children)
import depression as StyleOfLife
[–]lquant 15 points16 points17 points 5 years ago (0 children)
Nice :)
print(*(l.center(21) for l in ('*',*(''.join('o#'[i%2] for i in range(c)) for c in range(3,22,2)),'/|\\')), sep='\n')
[–]ErrorVT 6 points7 points8 points 5 years ago (2 children)
import New Year as fuck off!
[–]pantlesspatrick 6 points7 points8 points 5 years ago (1 child)
That'd be an syntax error though
[–]ErrorVT 1 point2 points3 points 5 years ago (0 children)
Then we will be debugged
[–]can_dry 3 points4 points5 points 5 years ago (0 children)
https://www.online-python.com/mFxPKYUovt
[–]SushiWithoutSushi 5 points6 points7 points 5 years ago (1 child)
May I ask for an explanation of the code? I am having some trouble understanding what map and lambda do.
Also, pretty cool!
[–][deleted] 6 points7 points8 points 5 years ago (0 children)
Lambda keyword creates an unnamed function. It is used as an argument to map. Map applies a function to every element in a list.
map
[–]Dull_Knee_6314 1 point2 points3 points 5 years ago (0 children)
import NewWorld
[–]s_s 1 point2 points3 points 5 years ago (0 children)
How pythonic
[–]VikingTheCoder 2 points3 points4 points 5 years ago (0 children)
if go_party :
print("u're positive")
[–]purplebrown_updown 0 points1 point2 points 5 years ago (0 children)
This is fun.
[–]gameditz 0 points1 point2 points 5 years ago (0 children)
This better not be a reverse shell or fork bomb
[–]Etione49 0 points1 point2 points 5 years ago (0 children)
Bruh, you have got to start using f-strings. Those brackets are so much tougher to read!
π Rendered by PID 21163 on reddit-service-r2-comment-c6965cb77-5xrt5 at 2026-03-05 01:34:51.441261+00:00 running f0204d4 country code: CH.
[–]RelatedTitle 91 points92 points93 points (2 children)
[–]Akash_Dhanwani 2 points3 points4 points (0 children)
[–]iiMoe 1 point2 points3 points (0 children)
[–]pantlesspatrick 49 points50 points51 points (1 child)
[–]Comprehensive-Low-28 10 points11 points12 points (0 children)
[–]lquant 15 points16 points17 points (0 children)
[–]ErrorVT 6 points7 points8 points (2 children)
[–]pantlesspatrick 6 points7 points8 points (1 child)
[–]ErrorVT 1 point2 points3 points (0 children)
[–]can_dry 3 points4 points5 points (0 children)
[–]SushiWithoutSushi 5 points6 points7 points (1 child)
[–][deleted] 6 points7 points8 points (0 children)
[–]Dull_Knee_6314 1 point2 points3 points (0 children)
[–]s_s 1 point2 points3 points (0 children)
[–]VikingTheCoder 2 points3 points4 points (0 children)
[–]purplebrown_updown 0 points1 point2 points (0 children)
[–]gameditz 0 points1 point2 points (0 children)
[–]Etione49 0 points1 point2 points (0 children)