Menu Close

Python String swapcase() Method

Python string swapcase

In this article, you will learn about the Python string swapcase() method to swap the lower case to uppercase and vice versa. swapcase in python method is used when you want to work with string in python.

In the previous tutorial, we have seen Python string startswith function to check whether a string with specified prefix or not.

Python swapcase() string method

Python swapcase() string method is used to convert lowercase to uppercase and uppercase to lowercase. It does not require any parameter and return a new string after conversion.


The syntax of string swapcase function in Python.


Return Value

The swapcase function in Python return new string.

Python string swapcase example:

Here we will take some example to understand python string swapcase method

Example 1:

result = a.swapcase()

Example 2:

a = 'Programming'
result = a.swapcase()

Example 3:

a = ['Programming', 'FUNDA', 'is', 'a', 'educational', 'site']
result = []
for i in a:


['pROGRAMMING', 'funda', 'IS', 'A', 'EDUCATIONAL', 'SITE']


In this tutorial, You have learned the Python string swapcase method to swap the uppercase to lowercase and vice versa. swapcase in python is the best string function to convert uppercase to lowercase and lowercase to uppercase at the same time.

I hope this tutorial will help you. if you like this article, please share it with your friends who want to learn Python programming.

Other string methods

For More Information:- Click Here

Python String startswith() Method
Python String rjust() Method

Related Posts