What is swapcase() function in the Python?

It is a string’s function which converts all uppercase characters into lowercase and vice versa. It is used to alter the existing case of the string. This method creates a copy of the string which contains all the characters in the swap case. If the string is in lowercase, it generates a small case string and vice versa. It automatically ignores all the non-alphabetic characters. See an example below.

string = “IT IS IN LOWERCASE.”
print(string.swapcase())

string = “it is in uppercase.”
print(string.swapcase())
it is in lowercase.
IT IS IN UPPERCASE.