Ad
  • Custom User Avatar

    So what I was missing (and that other guy's explanation fails to explain) is that when slicing a string to return a substring the : denotes a start and end point. s[] doesn't JUST return a specific indice. You can use it to return a substring from a starting indice to an ending indice. What the other guy is explaining is that the math works out so that on an odd string the equations on both sides of the : return the same number, so a string with 11 characters would be sliced starting at the 5th (starting from 0) indice and ending at the 5th indice. And even string length returns two different indices, so the one liner works.

    I had to look this up, his explanation did not make sense to me at first either, and frankly I will always pefer easily readable functions to one liners like this in actual production.

  • Custom User Avatar

    oh, this made me feel dumb. Its so simple.

  • Custom User Avatar
  • Custom User Avatar

    Check your alphabet, you have a typo there.

  • Custom User Avatar

    nothing's stopping you from using print to observe what is happening there.

  • Custom User Avatar

    Without seeing your code, we do not understand what is causing the error either.

  • Custom User Avatar

    I don't understand what is causing this error:
    Traceback (most recent call last):
    File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
    func()
    File "/workspace/default/tests.py", line 47, in tests
    test.assert_equals(printer_error(s), exp)
    ^^^^^^^^^^^^^^^^
    File "/workspace/default/solution.py", line 34, in printer_error
    if alphabet.get(letter) > 13:
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: '>' not supported between instances of 'NoneType' and 'int'

    all of the normal test cases pass just fine. The instructions state that the string will always be greater or equal to 1 in length, I covered every letter of the alphabet, and the instructions state the string will only include letters from a to z, so what could I possibly be missing?

  • Custom 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

  • Custom User Avatar

    Go to stack overflow if you want to actively be unhelpful.

  • Custom User Avatar

    why isn't that helping? is that still the information you're looking for or something else?
    ask specific things. if you failed to google, then google better xd - include the language, avoid special characters

  • Custom User Avatar

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

  • Custom User Avatar

    from cursory googling, the integer.sum method only accepts two numbers as parameters. How does this work with the stream function?