Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 170
    that's pretty neat and clever but I wouldn't use it because it's confusing to read. Commented Jun 15, 2010 at 18:55
  • 117
    This is a Shlemiel the painter's algorithm joelonsoftware.com/articles/fog0000000319.html -- unnecessarily inefficient as well as unnecessarily ugly. Commented Apr 25, 2012 at 18:24
  • 74
    The append operation on lists forms a Monoid, which is one of the most convenient abstractions for thinking of a + operation in a general sense (not limited to numbers only). So this answer deserves a +1 from me for (correct) treatment of lists as a monoid. The performance is concerning though... Commented Dec 3, 2014 at 10:35
  • 23
    this is a very inefficient way because of the quadratic aspect of the sum. Commented Jul 31, 2017 at 18:04
  • 13
    This article explains the maths of the inefficiency mathieularose.com/how-not-to-flatten-a-list-of-lists-in-python Commented Jan 4, 2018 at 16:46