YouTip LogoYouTip

Att String Swapcase

# Python2.x Python swapcase() Method [![Image 3: Python Strings](#) Python Strings](#) * * * ## Description The Python **swapcase()** method is used to convert the case of letters in a string, **converting uppercase letters to lowercase and lowercase letters to uppercase**. ## Syntax The syntax for the **swapcase()** method is: str.swapcase(); ## Parameters * NA. ## Return Value Returns a new string with the case of letters converted. ## Example The following example demonstrates the usage of the swapcase() function: ## Example #!/usr/bin/python str = "TUTORIAL!!!"; print(str.swapcase()); str = "tutorial!!!"; print(str.swapcase()); str = "abCDE--Tutorial!!!"; print(str.swapcase()); The output of the above example is: tutorial!!! TUTORIAL!!!ABcde--rAnDoM!!! * * Python Strings](#)
← Att String TitlePython Reg Expressions β†’