Python - String swapcase() Method


Advertisements

The string swapcase() method is used to convert all lowercase characters of the string into uppercase and all uppercase characters of the string into lowecase. Any symbol, space, special character or number in the string is ignored while applying this method. Only Alphabets are converted.

Syntax


string.swapcase()

Parameters

No parameter is required.

Example:

In the below example, swapcase() method is used to convert all lowercase characters of the string into uppercase and all uppercase characters of the string into lowercase.

MyString = "Hello John!"
print(MyString.swapcase())

Output

hELLO jOHN!

String Methods
Advertisements