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.
Wow, guess I learned something new today! :D
.
the kata has random tests now, and this solution does not pass the tests anymore
','
,', '
or,
.I can't for the life of me figure out what that last "..or
,
" is supposed to mean.This comment is hidden because it contains spoiler information about the solution
i think about mapping, but dont know there is all function in py, greate and readable
this method is actually faster than the "best practice" solution
This comment is hidden because it contains spoiler information about the solution
Nice way
im a noob to python how is that a function ? Someone pls explain.
This comment is hidden because it contains spoiler information about the solution
Good
I wanna sushiii
Good one. I will try to remember that code to future tasks
sum
takes an iterable as its primary argument and sums all the values in that iterable. This can be a list or array-like structure, but here we see it can also be a generator comprehension, which is a clause of the formexpr for vars in source [if condition]
. The generator comprehension iterates through thesource
, expanding each element into the one or more variables ofvars
, testing if the optionalif
expression is true, and then if so, yielding the results of evaluatingexpr
. You can think of a generator as an internal function of its own that can return multiple values, generated one at a time. Later, you might learn how to use theyield
keyword to do the same with any function. But until then, remember calling return always ends the function and returns a value. That means if you put it inside of a loop, it will abort that loop and end the function right then. Sometimes that can be handy, but not here. You want to loop through every value in arr, and a comprehension will do that.Loading more items...