Ad
  • Custom User Avatar

    You have code there that is not used.

  • Custom User Avatar

    From my point of view, the function could be split into two distinct parts. The first part (the for loop that counts uppercase and lowercase characters) could be moved into a separate function that simply returns those counts. Also, the else case with the pass statement in the loop isn’t necessary and can be removed to simplify the code.

    The same applies to the second part of the function. You could eliminate one of the else cases and move the logic into another function as well.

    With these improvements, the purpose of the solve function becomes much clearer: it counts the number of uppercase and lowercase characters and then converts the string to either lowercase or uppercase based on that count—without needing to dive into the implementation details.

    Actually, after reviewing my own code, I’ve decided to refactor it too. Thanks for the feedback! 😄 I realize I was trying to do too many things at once.

  • Custom User Avatar

    Which part didnt you understand

  • Custom User Avatar

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

  • Custom User Avatar

    You should not user one letter to describe variables. It should be descriptive.

  • Custom User Avatar

    Code not clear enougth

  • Custom User Avatar

    Clever, but this code is less readable than if you split it into several functions with explicit names.