C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Python String swapcase() MethodPython swapcase() method converts case of the string characters from uppercase to lowercase and vice versa. It does not require any parameter and returns a string after case conversion. Signatureswapcase() ParametersNo Parameter ReturnIt returns a string. Let's see some examples of swapcase() method to understand it's functionality. Python String swapcase() Method Example 1It is a simple example to convert uppercase to lowercase using the swapcase() method. # Python String swapcase() method # Declaring variable str = "HELLO JAVATPOINT" # Calling function str2 = str.swapcase() # Displaying result print (str2) Output: hello TheDeveloperBlog Python String swapcase() Method Example 2This example describes conversion from lowercase to uppercase. # Python String swapcase() method # Declaring variable str = "hello TheDeveloperBlog" # Calling function str2 = str.swapcase() # Displaying result print (str2) Output: HELLO JAVATPOINT Python String swapcase() Method Example 3If the string is in camelcase, the output of this method also would be in camelcase. All the lowercase will be converted to uppercase and vice versa. # Python String swapcase() method # Declaring variable str = "Hello JavTpoint" # Calling function str2 = str.swapcase() # Displaying result print (str2) Output: hELLO jAVtPOINT
Next TopicPython Strings
|