Swapcase() Method Of Str Class

Method Name:

swapcase

 

Method Signature:

swapcase()

 

Method Overview:

  • The method swapcase() converts all the lowercase characters of the string object into upper case and all the uppercase characters the string object into lower case and returns a new string object.

 

Example:

sampleString    = "That is only the box. The sheep you asked for is inside"

caseSwapped     = sampleString.swapcase()

 

print("Before case swap :%s"%(sampleString))

print("After case swap :%s"%(caseSwapped))

 

Output:

Before case swap :That is only the box. The sheep you asked for is inside

After case swap :tHAT IS ONLY THE BOX. tHE SHEEP YOU ASKED FOR IS INSIDE


Copyright 2019 © pythontic.com