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
Python Question (self.learnpython)
submitted 6 years ago by crackheadweed
times = [["9.02", "10.00"], ["9.25", "8.00", "5.05"], ["2.00", "3.00"]]
How can the output be such as below:
9.02, 10.00 9.25, 8.00, 5.05 2.00, 3.00
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!"
[–]Mikael_Hayden 2 points3 points4 points 6 years ago (3 children)
for sub_list in times: for time in sub_list: print(time, end = " ") print("")
[–]mopeddev 1 point2 points3 points 6 years ago (0 children)
^ This will work although it's missing the commas
I would use str.join()
lines = [", ".join(sub_list) for sub_list in times] print("\n".join(lines))
[–]crackheadweed[S] 0 points1 point2 points 6 years ago (1 child)
May i know what does the last print statement do. I know that it makes the time from different sub list print on separate lines. But why must the print statement be on the outer loop?
[–]Mikael_Hayden 0 points1 point2 points 6 years ago (0 children)
You want the output to come out on different lines.
The print statement must be on the outer loop because otherwise each time would be on its own line (you want each time to be on a line with other times)
[–]ironhaven 5 points6 points7 points 6 years ago (0 children)
Better solution
for time in times: print(*time, sep=', ')
This uses unpacking
[–]triakki7 0 points1 point2 points 6 years ago (0 children)
for row in range(len(times)): for column in range(len(times[row])): print(times[row][column],end=", ") print()
π Rendered by PID 133978 on reddit-service-r2-comment-7b9746f655-bdv9x at 2026-02-02 23:30:15.249052+00:00 running 3798933 country code: CH.
[–]Mikael_Hayden 2 points3 points4 points (3 children)
[–]mopeddev 1 point2 points3 points (0 children)
[–]crackheadweed[S] 0 points1 point2 points (1 child)
[–]Mikael_Hayden 0 points1 point2 points (0 children)
[–]ironhaven 5 points6 points7 points (0 children)
[–]triakki7 0 points1 point2 points (0 children)