Ad
  • Custom User Avatar

    They don't.
    The code you describe would return the first element of a list, while the solution above returns a list comprehension. In the later case, the whole list gets populated before the return statement executes.

    Your described solution could come closer by using yield instead of return, except the return type would be a generator and not a list. Which means, for this to work you need a statement that would not interrupt the for-loop.

  • Custom User Avatar

    See negation (arithmetic) among Python operators.

  • Custom User Avatar

    This is a list comprehension. It creates a new list while iterating over lst.

  • Custom User Avatar

    Oh, nice!
    Always found it boring to compile the pattern...
    Thanks

  • Default User Avatar

    @frenetic_be: I just translated this kata for Python, could you have a look?

  • Default User Avatar

    Could I have any help about my issue instead of hidding my comment (while I do not remember giving any technical informations about a solution)?
    I still get unexplained SIGSEGV error on the full test suite.

  • Default User Avatar

    +1 for this idea, I would have upvoted your fork first :)
    I support your suggestion on github.

  • Default User Avatar

    Hi,
    Thanks! It's better now.
    Though I notices it could fail occasionally, going to refactor right now.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Hi,
    There is a problem with basic test cases of this Kata in Python.
    This test case: Test.assert_equals(mix("looping is fun but dangerous", "less dangerous than coding"), "1:ooo/1:uuu/1:ii/2:sss/2:aa/2:dd/2:ee/=:nnn/=:gg")_.
    The expected solution is not right as I was stuck with is for testings but my solution worked with the final application.

    BTW it is True that finishing this kata is more like resolving an enigma than just find the right implementation. Not sure is it really the point of CodeWars katas.

  • Custom User Avatar

    Hi,
    Very weird issue here: I'm both printing and returning the answer to check whether my solution works OK, and for test case #3 it prints the answer 'e' which is correct, but I get error 'None should equal "e"'.
    Even using a dirty fix to pass by, I get a similar issue in the following test cases when trying to apply my solution.

    Can't figure how the interpreter could print a variable's value as a string in one line, then return it as None the line rigth after...
    Any thoughs?

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution