Need help with python code

Hi all,

Below is the question and the code written to get a desired output.

Iam not getting the desired output, need some help in understanding the mistake i have done.


Thanks in advance.

Your code doesn’t handle case properly. swapcase() swaps the case, but that only turns ‘aPple’ into ‘ApPLE’, which is probably not what you want.

Overall, your code is quite a convoluted way to approach this problem, which makes it more difficult to understand why it’s not working as it should. Think about whether you can remove any of your type conversions or loops.

1 Like