Suppose we have a string with English letters. We have to swap the case of the letters. So uppercase will be converted to lower and lowercase converted to upper.
So, if the input is like s = "PrograMMinG", then the output will be pROGRAmmINg
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding
def solve(s): ret = '' for letter in s: if letter.isupper(): ret += letter.lower() else: ret += letter.upper() return ret s = "PrograMMinG" print(solve(s))