Python3 swapcase() Method
Description
Python swapcase()The method is used to convert the case of letters in a string,i.e., it converts uppercase letters to lowercase, and lowercase letters to uppercase.。
Syntax
swapcase()Method syntax:
str.swapcase();
Parameters
- NA。
Return Value
Returns a new string generated after case conversion of letters.
Example
The following example demonstrates the usage of the swapcase() function:
Example
#!/usr/bin/python
str = "EXAMPLE!!!";
print ( str.swapcase() );
str = "example!!!";
print ( str.swapcase() );
str = "abCDE--example!!!";
print ( str.swapcase() );
The output of the above example is as follows:
example!!! EXAMPLE!!! ABcde--example!!!
Other Extensions
Python3 Strings