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.
The most important thing here is the list comprehension (sum(int(x)) for x in str(value)
It is nothing but a for loop, you will write hundreds of for loops until it just clicks that what you're trying to do is this essential form, and then it comes naturally.
the more you see it the more obvious it gets
same here LOL
thats clever
when using list comprehensions, if you have no else to add, you should use the if after the for not before it. I guess that's the reason
try it yourself.
This reply might make sense if you used modulo extraction to do it completely mathematically, but you used a method that is still O(n) in space complexity so the difference between your code and the given solution is barely different.
This isn't quite correct. That isn't a list expression, its a lazy generator. There is no intermediate list of 1s created, rather it yeilds a 1 each time it is requested by the sum function.
I am still new to python but I wonder how does someone think about these one liner clean code, does it come after few iterations or they pop up just like that :)
Personnaly I do it because it is fun to do. It also test my knowledge of a language and allow me to improve on this language.
However, I avoid to do those kind of thing for professional code and always favor readable and easily understable code.
Codewars is not real life project guys, it is fun to have those kind of solution upvoted, it show of what a language can do and help reader to improve, even if it should not be applied in a professional context !
Perfect!
Useful when you want to learn 'not in' list
nice job
Short for letter?
Can someone explain why all these 56++ persons all using same "let" as variable name? let in this code is not python reserver function but variable name.
Beautiful, simple and efficient.
I tried this one but it kept asking me to add an else statement
Loading more items...