Ad
  • Custom User Avatar

    This is nicely structured but I would change the variable name from ret to something more meaningful

  • Custom User Avatar

    This is clever indeed but also makes the code too vague

  • Custom User Avatar

    Comprehensions are used very commonly in real-life scenarios. It's even in the google style guide to use them when the expressions are not overly complicated.

    Lambda function are a different story, though. While lambdas are commonly used for simple functions, you wouldn't normally use them as many of the solutions do here. Creating a lambda function and then assigning it to a variable sort of defeats the purpose of a lambda function unless you're using it to nest functions, and even then you'd only do that for very simple functions. However, most people on codewars just use them to reduce the number of lines in their code.

  • Custom User Avatar

    This is actually clever, well done!

  • Custom User Avatar

    here are few examples to simplify it:
    map(int, a) --> apply int to every list object in list a to make them integers
    map(str, a) --> apply str to every list object in list a to make them strings

  • Custom User Avatar

    Its nice to see this type of solution where the its "opened up" with empty list and normal for loop. There's a lot of solutions with lambda and comprehension (one liners) but these dont add that much value to real life scenarios when the talking point is maintanability. :)