The swapcase() function in python helps to return a copy of the original string in which all the uppercase characters of the string are converted into lowercase also all the lowercase characters of the string are converted into uppercase.
string.swapcase()
The swapcase() method doesn't take any parameters. If we call this function all the cases (Upper& Lower) will be reversed.
The return value is always a string. At the time of conversion, all symbols and letters are ignored.
Input | Return Value |
---|---|
string | upper & lower converted string |
# example string
string1 = "CONVERTING INTO LOWERCASE."
print(string1.swapcase())
string2 = "converting into uppercase."
print(string2.swapcase())
string3 = "String Have Both Upper And Lowercase."
print(string3.swapcase())
Output:
converting into lowercase. CONVERTING INTO UPPERCASE. sTRING hAVE bOTH uPPER aND lOWERCASE.
string = "HI HOW ARE YOU?"
print(string.swapcase())
string = " I am fine."
print(string.uppercase())
Output:
hi how are you? IAM FINE.