Last active
November 10, 2021 19:13
-
-
Save RHDZMOTA/ed676de4927ccbfe189d11c1084616ad to your computer and use it in GitHub Desktop.
Swap-case in Python without using the swapcase built-in method.
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
# Challenge: implement swapcase without using the built-in method | |
def swapcase(string: str) -> str: | |
return "".join( | |
char.lower() if char.isupper() else char.upper() | |
for char in string | |
) | |
assert swapcase("AbCd") == "aBcD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment