Python String swapcase() Method

Python 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.

Signature

Parameters

No Parameter

Return

It returns a string.

Let's see some examples of swapcase() method to understand it's functionality.

Python String swapcase() Method Example 1

It is a simple example to convert uppercase to lowercase using the swapcase() method.

Output:

hello javatpoint

Python String swapcase() Method Example 2

This example describes conversion from lowercase to uppercase.

Output:

HELLO JAVATPOINT

Python String swapcase() Method Example 3

If 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.

Output:

hELLO jAVtPOINT

Next TopicPython Strings




Latest Courses