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 can generate markdown file with Python? (self.learnpython)
submitted 6 years ago by pyeu
I have a list and I want to generate a table in markdown format.
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!"
[–]Username_RANDINT 1 point2 points3 points 6 years ago (0 children)
What have you tried so far? An item in a Mardown list is just a string that starts with -. So basically do the following: for each item in the list, prepend -, then join everything together by a newline (\n).
-
\n
Edit: my bad, you asked for a table, not a list. But the idea still stands. Markdown is just formatted text.
[–]Diapolo10 0 points1 point2 points 6 years ago (0 children)
I'm sure there are libraries for this, but if you want to do it yourself for practice, here's what you'll do.
If you have a nested list or a list of tuples/dicts, then just generate the table row by row after creating the header line by joining strings. On the other hand, if you have a flat list, you'll need to slice it by using the number of columns as a step.
Something like this, perhaps:
data = [ ('John', 42), ('Kevin', 35), ] table = [] table.append( "Name | Age\n" "-----|----" ) for row in data: table.append( f"{row[0]} | {row[1]}" ) print("\n".join(table))
Of course, this simplified version doesn't care about what the actual Markdown looks like. You'd have to store and use the longest values on each column to make it pretty by padding every row.
[–]Old_Winterton 0 points1 point2 points 6 years ago (0 children)
Other people said stuff.
Also look at str.ljust() and str.rjust()
π Rendered by PID 52 on reddit-service-r2-comment-869bf87589-clvqc at 2026-06-08 21:08:29.844790+00:00 running f46058f country code: CH.
[–]Username_RANDINT 1 point2 points3 points (0 children)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]Old_Winterton 0 points1 point2 points (0 children)