text = "Hello World"
result = text.swapcase()
print(result) # Output: "hELLO wORLD"
my_str='Welcome to plus2net Python Section'
output=my_str.swapcase()
print(output)
Output is here
wELCOME TO PLUS2NET pYTHON sECTION
Working with numbers and special characters:text = "Python3.9 is AWESOME!"
result = text.swapcase()
print(result) # Output: "pYTHON3.9 IS awesome!"
Handling mixed case strings:
text = "WeLcOmE tO PyThOn"
result = text.swapcase()
print(result) # Output: "wElCoMe To pYtHoN"
text = "Python3.8 is AWESOME"
result = text.swapcase()
print(result)
Output
pYTHON3.8 IS awesome
text_list = ["Hello", "World", "Python"]
swapped = [text.swapcase() for text in text_list]
print(swapped)
Output
['hELLO', 'wORLD', 'pYTHON']
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.