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, this is actually an incredibly helpful (yet simple) explanation! Thank you so much
On Codewars, you need to write functions that need to
return
the wanted values. Printing to console is useful if you personally want to read the result, but the rest of the program can't do anything with it.Functions are called to perform certain actions. In many cases, you want a function to simply perform a task and return a result back so that the program can use that result for futher calculations.
A
return
command stops the current function and returns the values back to the function that called it.An example for a function that uses the return value of another function:
If you run a function that does not print to console in your IDE, it might work, but you won't see any results. If you want to check the result of your function for a certain input, use
print(count_sheep(3))
after your function (not inside it).This comment is hidden because it contains spoiler information about the solution