Ensure that you are logged in and have the required permissions to access the test.


33
Swap case function in python
Python
String-formatting

In python there is a very handy method to change case of letters in a string.
The method swapcase() returns a copy of the string in which all the case-based characters have had their case swapped. This automatically ignores non-alphabetic characters.

The following example shows the usage of swapcase() method :-

str = "this is string example....wow!!!";
print str.swapcase()

str = "THIS IS STRING EXAMPLE....WOW!!!";
print str.swapcase()

When we run above program, it produces following result −

THIS IS STRING EXAMPLE....WOW!!!
this is string example....wow!!!

?