Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
That's what "clever" means when you're coding in Python
exactly
That is the solution in essence, but it is hard to read, not to mention that debugging is almost impossible as is.
Python is a very verbose and explicit language. We shouldn't neglect that in favor of shorter code, I think.
Also, it "kills 2 birds with one stone", because it checks if
arr
is None as well. It could be subtle, but if one gets used to it it really becomes an elegant way to check for empty list and None.Because you want the count of the positive numbers. Each x that is positive gets represented by 1 in the new array. A sum of the array with 1s is essentially a count of the positive numbers.
Doesn't work for None
Isn't this running all operations rather unnecessary?