Latest web development tutorials

Python3 swapcase () method

Python3 string Python3 string


description

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/python3

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!!!
tHIS iS sTRING eXAMPLE....wow!!!

Python3 string Python3 string