Created
February 11, 2024 03:14
-
-
Save dcortesnet/4442ea87b5136bc924fa3e94896e54fb to your computer and use it in GitHub Desktop.
Python revertir casos de mayúsculas y minúsculas
This file contains 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 swap_case(text: str): | |
swap = "" | |
for word in text: | |
if word.isupper(): | |
swap += word.lower() | |
continue | |
if word.islower(): | |
swap += word.upper() | |
continue | |
swap += word | |
return swap | |
text = "HeLLo. H" | |
print(swap_case(text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment