In this article, you will see how to swapcase string in Python. The swapcase means to convert all uppercase characters to lowercase and all lowercase characters to uppercase. In Python, you can use the swapcase()
method to swapcase a string.
Step 1: Create a string
str = "CodeAllow" print("str = ", str) print("str type = ", type(str))
Step 2: Swapcase string
print("Swapcased = ", str.swapcase())
Output:
str = CodeAllow
str type = <class 'str'>
Swapcased = cODEaLLOW
Free resources to learn advanced skills: AiHints and CodeAllow