YouTip LogoYouTip

Python3 String Swapcase

# Python3.x Python3 swapcase() Method [![Image 3: Python3 Strings](#) Python3 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 = "!!!"; print(str.swapcase()); str = "!!!"; print(str.swapcase()); str = "abCDE--!!!"; print(str.swapcase()); The output of the above example is as follows: !!! !!!ABcde--!!! * * Python3 Strings](#)
← Java Arraylist ClearJava Arraylist Add β†’