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.
I was being Pythonic when I wrote this. I would agree that x!=0 is more readable. https://docs.python-guide.org/writing/style/
It could equally have been used and would have been more readable IMO. As to why it was not? Perhaps the author preferred a shorter solution, or perhaps they find it just as readable, perhaps perhaps perhaps...
This comment is hidden because it contains spoiler information about the solution
It is part of the loop, and it filters all
x
that are not a falsy value (0, False, empty string, etc). Look up list comprehension for more details.can someone tell me what is the role played here by "if x" after for loop in the program
Much better than the top one. Cleanest and most intuitive so far.
Still linear though.
super dig this one
it's not better in terms of time complexity as it would have O(2n) time complexity compare to the first one which has O(n)
and that's because this solution iterates through the list twice:
1- on the construction of the first liste comprehension
2- when counting the number of zeros in the list
Thank you!
I love this solution, definitely better than what's #1. Very simple and intuitive
I understand now, the '0's are considered False so they are skipped. Thank you
This comment is hidden because it contains spoiler information about the solution
In my opinion this is the better solution compared to the #1 right now. Same length, similar readability but much more intuitively comprehensible.
I like it! On my opinion it is near pythonic solution. Look so simple
Loading more items...