Created
September 24, 2021 05:59
-
-
Save pamelafox/af00a8e1f7167b71bb26615a049b6cab to your computer and use it in GitHub Desktop.
fUnkyCaSe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fUnKyCaSe(text): | |
"""Returns TEXT in fUnKyCaSe | |
>>> fUnKyCaSe("wats up") | |
'wAtS Up' | |
""" | |
def toggle_case(letter, should_up_case): | |
return letter.upper() if should_up_case else letter.lower() | |
def up_down(text, should_up_case): | |
if len(text) == 1: | |
return toggle_case(text, should_up_case) | |
else: | |
return toggle_case(text[0], should_up_case) + up_down(text[1:], not should_up_case) | |
return up_down(text, False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment