Latest web development tutorials

Python swapcase () method

Python strings Python strings


description

Python swapcase () method is used to convert a string of uppercase and lowercase letters.

grammar

swapcase () method syntax:

str.swapcase();

parameter

  • NA.

return value

Returns a new string case letters after conversion generated.

Examples

The following example shows swapcase () function to use:

#!/usr/bin/python

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

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

Examples of the above output results are as follows:

this is string example....wow!!!

Python strings Python strings