String Methods
str.swapcase()
Exchange uppercase and lowercase mappings in a string. This is not guaranteed to be an involution: expansion and context-dependent Unicode transformations can prevent a second call from restoring the input. Characters without case stay unchanged. The receiver is immutable; the operation returns a string without modifying it. Do not rely on a new object identity.
Formal Syntax & Structure
python syntaxpython
text.swapcase()Return Value
str
String containing the transformed text.
Working Example
Example Snippetpython
label = "Read API 7"print(label.swapcase())print("Maße".swapcase())print("Maße".swapcase().swapcase())