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've seen this taught in a few beginner python courses like the videos on coderbyte unfortunately
No blame! Just wanted to mention it to people new to the language.
blame the author/translator... ;)
Important note: it is a best practice to not recycle or shadow internal names like 'str'.
aw man, I assumed numpy wouldn't be available.
I agree. It's hard to fix bugs for test cases you can't read.
Sure, I see that. My intent in commenting was merely to point out to others that are learning the craft/language that lambdas generally shouldn't be assigned to names.
EDIT: Poking around the site, I see that there are a lot of code golf type answers around. I guess it's probably not worth being so pedantic around here.
As I should normally agree with you, you seem to forget that main purpose of PEP 8 is to provide some guidance to write cleaner code, not to be an absolute reference when coming to code conventions.
PEP8 introduction states itself that
The only moment when you have to follow PEP8 strictly and blindly is when writing an official builtin module for Python distribution itself. Even third party packages listed on PyPi are not confined to PEP8 recommendations.
So please keep in mind that this solution main purpose is code golf - a type of recreational computer programming game where an answer is favoured for its shortness rather than its clearness and designed to be entertaining.
That is also the reason why CodeWars provides two distinct categories to classify solutions:
Assigning a lambda expression to a name is a PEP8 violation, though:
https://www.python.org/dev/peps/pep-0008/#programming-recommendations