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.
This comment is hidden because it contains spoiler information about the solution
Pairs is outside the function definition because it is essentially a constant. That means it is safe to put in the global space, and that way we aren't reallocating for it constantly. Python, because it is interpretted, can't always optimize stuff like this the way C++ compilers can.
I probably should've called it
PAIRS
instead to make it clearer that it was a constant.Definitely good thing for people to take note of.
I would include, however, that in this case, it doesn't just not matter, but it would be incorrect.
When you give a function invalid input, it should throw an error. Catching it unnecessarily can quickly put you in a position where a program fails silently, which is much harder to debug.
Short version: We don't know what to do with any letter other than these four, there's no defined behavior, so we SHOULD get an error.
Yes! Please, please get used to them. As well as set and dictionary comprehensions. They can do so much for you in such a clear and concise way. They seem hard to understand at first, but when you get used to them you can read them like sentences.
Sure, true, but I think including them is clearer. If the braces got any more cluttered, I'd consider leaving them out.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution