/  swapcase() method in Python String Module

swapcase() method in Python String Module


swapcase methodin string module returns all the lowercase alphabets in a string into uppercase and all the uppercase alphabets into lowercase.


Syntax:

str.swapcase()


Example-1:

Swapping of lowercase alphabets into uppercase.

text = "today is friday"
x = text.swapcase()
print(x)


Output :


Example 2:

Swapping of uppercase alphabets into lowercase.

text = "uetliberg is SURROUNDED BY MOUNTAINS AND LAKES"
x = text.swapcase()
print(x)


Output: