Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created September 24, 2021 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamelafox/af00a8e1f7167b71bb26615a049b6cab to your computer and use it in GitHub Desktop.
Save pamelafox/af00a8e1f7167b71bb26615a049b6cab to your computer and use it in GitHub Desktop.
fUnkyCaSe
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