
swapcase() method –
The swapcase() method converts all uppercase characters to lowercase characters and all lowercase characters to uppercase and returns it.
Syntax –
string.swapcase()
Examples –
In [1]: string1 = 'WE LOVE PYTHON'
In [2]: string1.swapcase()
Out[2]: 'we love python'
In [3]: string2 = 'we love python'
In [4]: string2.swapcase()
Out[4]: 'WE LOVE PYTHON'
In [5]: string3 = 'We Love Python'
In [6]: string3.swapcase()
Out[6]: 'wE lOVE pYTHON'
Related Posts –
- Python String Method – Capitalize()
- Python String Method – title()
- Python String Method – center()
- Python String Method – count()
- Python String Method – startswith()
- Python String Method – endswith()
- Python String Method – find()
- Python String Method – index()
- Python String Method – isalnum()
- Python String Method – isalpha()
- Python String Method – isdecimal()
- Python String Method – isdigit()
- Python String Method – islower()
- Python String Method – istitle()
- Python String Method – isupper()
- Python String Method – join()
- Python String Method – lower()
- Python String Method – upper()