Python string | swapcase ()

Python Methods and Functions | String Variables

Syntax :

string_name.swapcase ()
Here string_name is the string whose cases are to be swapped.

Parameter: the swapcase () method takes no parameters.

Returned value:

The swapcase () method returns a string with all the cases changed.

Below is the implementation of the swapcase () method in Python.

# Python program to demonstrate usage
# swapcase () method

  

string = "gEEksFORgeeks"

 
# prints after replacing all cases

print (string.swapcase ()) 

  

string = "striver"  

print (string.swapcase ()) 

Output:

 GeeKSforGEEKS STRIVER 




Tutorials