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.
Thank you so much, you put it so clearly to understand, I learned something new today! Greatly appreciated!
Hi yellowboyvn,
When you set your parameter (n) to something, you are saying you want that "something" to be your default value in case the funcion is called without a value. It prevents errors.
So, if we call our function empty, it will assume the input is 0 in our case (or any value you have assigned to it).
Hope that helps!
Hello I saw the comments for the problem but I do not quite understand what n=0 means in the parameter. I know that not setting n=0 will raise an error, would you (or somebody) mind explaining that to me please? Thank you kind person!
Hi Hugolarzabal,
Thank you very much!
I get it now. A quick follow up. The answer above doesn't have the f.
Is that f necessary?
Thank you again!
Josh
This comment is hidden because it contains spoiler information about the solution
Hi Josh,
Yeah, it can be a little hard in the beginning.
"i for i" (or "x for x", etc.) starts a loop that checks every element in the array in order.
For example, if you array is ['A', 'C', 'X', 'D'], it will first do ['A'] then ['C'] then ['X'] and finally ['D']. It puts them all together and returns that.
Maybe it's better you write it as "element for element" because the output will be the same.
And if you change it to "1 for element" it will do 1 for each element so the output will be [1, 1, 1, 1] in the same example.
Hope that clears it a little bit,
S
Can you please explain to me what the [i for i] part of the list comprehension means in plain English?
I still have trouble understanding that.
Thank you very much!
Josh