Skip to content

Instantly share code, notes, and snippets.

@raeq
Created July 18, 2020 11:11
Show Gist options
  • Save raeq/6b5e387f6988809a20e4640d416867c8 to your computer and use it in GitHub Desktop.
Save raeq/6b5e387f6988809a20e4640d416867c8 to your computer and use it in GitHub Desktop.
Change the case of a string
def to_uppercase(input_string:str) -> str:
return input_string.upper()
def to_lowercase(input_string:str) -> str:
return input_string.lower()
def to_sentencecase(input_string:str) -> str:
return input_string.capitalize()
def to_titlecase(input_string:str) -> str:
return input_string.title()
def to_swapcase(input_string:str) -> str:
return input_string.swapcase()
assert to_uppercase("the end of time") == "THE END OF TIME"
assert to_lowercase("The End Of Time") == "the end of time"
assert to_sentencecase("The End of Time") == "The end of time"
assert to_titlecase("the end of time") == "The End Of Time"
assert to_swapcase("The End Of Time") == "tHE eND oF tIME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment