DEV Community

Abubakar Sadiq Sirajo
Abubakar Sadiq Sirajo

Posted on

3 2

Python string | swapcase()

The string swapcase() method converts all uppercase characters to lowercase and vice versa of the given string and return it.

Syntax:

string_name.swapcase()

Here string_name is the string whose case are to be swapped.

Parameter:The swapcase() method does not take any parameter

Return value:
The swapcase() method returns a string with all the case changed.

Below is the python implementation of the swapcase() method

# Python program to demonstrate the use of
# Swapcase() method

string = "wORldGREAtestday"

# Print after swapping all case 
print(string.swapcase())

string = "python"
print(string.swapcase())

Enter fullscreen mode Exit fullscreen mode

Output:

WorLDgreaTESTDAY
PYTHON
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post