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 cases print(string.swapcase()) string = "striver" print(string.swapcase()) |
Output:
GeeKSforGEEKS STRIVER
Recommended Posts:
- Python String Methods | Set 1 (find, rfind, startwith, endwith, islower, isupper, lower, upper, swapcase & title)
- numpy string operations | swapcase() function
- Python | Pandas Series.str.swapcase()
- Python | Check if given string can be formed by concatenating string elements of list
- String slicing in Python to check if a string can become empty by recursive deletion
- Python | Merge Tuple String List values to String
- Python | Sorting string using order defined by another string
- Python | Check if string ends with any string in given list
- Python | Check if a given string is binary string or not
- String slicing in Python to rotate a string
- Python String
- Python | Add one string to another
- Python String | max()
- Python String | min()
- string.whitespace in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




