How did this get any votes for best practices? You're wrapping this in a try except block because passing an integer to the list constructor raises a TypeError. There's no reason to handle exceptions for this kata.
MDN recommends using a reduce function instead.To paraphrase: spread (...) will either fail or return the wrong result if the array has too many elements, because they try to pass the array elements as function parameters. The reduce solution does not have this problem.
How did this get any votes for best practices? You're wrapping this in a try except block because passing an integer to the list constructor raises a TypeError. There's no reason to handle exceptions for this kata.
This comment is hidden because it contains spoiler information about the solution
This is what I did too. I think a while loop works better for this kata than calling range()
I think the assumption is only broken pipes would be passed to the function.
This is way better than using a for loop.
MDN recommends using a reduce function instead.To paraphrase: spread (...) will either fail or return the wrong result if the array has too many elements, because they try to pass the array elements as function parameters. The reduce solution does not have this problem.