Python String swapcase() Method
Python swapcase() method is used to convert upper and lower case letters of a string, that is, upper case letters will be converted to lower case letters and lower case letters will be converted to upper case letters.
Python String swapcase() Syntax
swapcase() Method syntax.
str.swapcase();
Python String swapcase() Parameters
- None.
Python String swapcase() Return Value
Returns the new string generated by converting upper and lower case letters.
Python String swapcase() Example#1
The following example demonstrates the use of the swapcase() function.
#!/usr/bin/python
str = "APIDEMOS";
print ( str.swapcase() );
str = "apidemos";
print ( str.swapcase() );
str = "abCDE--ApiDemos";
print ( str.swapcase() );
Output: