Python String swapcase() Method

The Python swapcase() method is used to convert all uppercase characters to lowercase and vice versa of a given string. It returns a new string with the cases swapped.

For example:

text = "Hello World"
result = text.swapcase()
print(result)

# Output: hELLO wORLD

You can also use swapcase() on a string that contains a mix of upper and lower case characters. All cases will be reversed when swapcase() method is called.

For example:

text = "HeLLo WoRld"
result = text.swapcase()
print(result)

# Output: hEllO wOrLD

If you have any questions about this code, you can drop a line in comment.

Comments

Popular posts from this blog

Python chr() Built in Function

Python float() Built in Function

Python bool() Built in Function

Python Printing Readable Results

Python exec() Built in Function