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
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.