Python string | swapcase()
The string swapcase() method converts all uppercase characters to lowercase and vice versa of the given string, and returns it.
Syntax:
string_name.swapcase()
Here string_name is the string whose cases are to be swapped.
Parameter: The swapcase() method does not takes any parameter.
Return value:
The swapcase() method returns a string with all the cases changed.
Below is the Python implementation of the swapcase() method
# Python program to demonstrate the use of# swapcase() method string = "gEEksFORgeeks" # prints after swappong all casesprint(string.swapcase()) string = "striver" print(string.swapcase()) |
Output:
GeeKSforGEEKS STRIVER
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course


