Friday, March 9, 2018

String swapcase() Method


String swapcase() Method in Python 3


The swapcase() method returns a copy of the string in which all the case-based
characters have had their case swapped.

Syntax
str.swapcase();

Return Value
This method returns a copy of the string in which all the case-based characters have had their case swapped.

Example
#!/usr/bin/python3
str = "this is string example....wow!!!"
print (str.swapcase())
str = "This Is String Example....WOW!!!"
print (str.swapcase())

Result
THIS IS STRING EXAMPLE....WOW!!!
tHIS iS sTRING eXAMPLE....wow!!!