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
Post a Comment