Python String swapcase() Method

Example

Convert lowercase letters to uppercase, uppercase letters to lowercase:

txt = "Hello My Name Is Elon"
x = txt.swapcase()
print(x)

Running Instance

Definition and Usage

The swapcase() method returns a string in which all uppercase letters are converted to lowercase, and vice versa.

Syntax

string.swapcase()

Parameter Value

No Parameters.