The function of a string is to change all uppercase characters into lowercase ones and vice versa. Modifying the current instance of the string is utilized. All the characters in the swap case are copied in this method’s string. A small case string is produced when the string is in lowercase, and vice versa. It automatically disregards all characters that are not alphabetical. See an example below:
Example:
- string = “IT IS IN LOWERCASE.”
- print(string.swapcase())
- string = “it is in uppercase.”
- print(string.swapcase())
Output:it is in lowercase. IT IS IN UPPERCASE.