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.
bool
can be dropped?Hi,
I have one thing to add. If the list has already been created and used, then
len()
is an obvious option and it makes no sense so usesum()
. Here this isn't the case.Compare the two:
Here is an interesting article about time complexity in Python.
Regards,
suic
Hi,
I don't understand your comment. The point here isn't if
len()
is faster or slower thansum()
. The point is that forlen()
you need to build the whole list which you immediately throw away.sum
with a generator doesn't generate any list (=> memory efficient).Regards,
suic