Add more detailed docstring

This commit is contained in:
Edward Betts 2023-12-06 20:57:24 +00:00
parent d76c74395b
commit 98ea589c58

View file

@ -132,7 +132,27 @@ def index() -> str | Response:
def case_flip(s: str) -> str: def case_flip(s: str) -> str:
"""Switch case of character.""" """
Switch the case of a single character.
If the character is lowercase, it is converted to uppercase. If it is uppercase,
it is converted to lowercase. Non-alphabetic characters remain unchanged.
Args:
s (str): A single character string.
Returns:
str: The character with its case flipped, or the original character if it's
not a letter.
Example:
>>> case_flip('a')
'A'
>>> case_flip('A')
'a'
>>> case_flip('1')
'1'
"""
if s.islower(): if s.islower():
return s.upper() return s.upper()
if s.isupper(): if s.isupper():