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 would say yes that pattern recognition is a skill, as well as understanding the problem. Much of the complexity of this problem is in understanding it.
@sweetmercury true, i wished i actually written the resulting output rather than the triangle.
This comment is hidden because it contains spoiler information about the solution
Please, mark your post as having spoiler content next time, you're disclosing the solution. About your question, yes, that solution is faster and speed is one of the parameters you can measure a solution with.
Read this specially the memory stack part. If you don't return the call, it'll run your code n times, the result will be lost when returning from the stack and the default return value of Python is
None
. Use Pythontutor to see the difference.It's not the last line you have to change, only change the line I wrote first there (the line 8 in your posted code), with the other one, do you get why you should do that? Try reading a little more about how recursion works if not. Recursion is not that easy to understand if you're only starting to code, you could have used an iterative solution instead. This will be helpful to you too.
Read my answer again, I told you exactly what was wrong. I wasn't impolite at all.
I hope this is clear enough.
First, why the downvote? Then I already told you what your problem is, you need to return the recursive call to your function too, not only counter.
Yes, but because you didn't return the function call, that value is lost.
No, I never said that.
As many others, you're doing recursion wrong, not returning the call to the function. Also, read this about using markdown formatting, amongst other things.