Created
April 29, 2022 19:24
-
-
Save carc1n0gen/98f86a82f051c99441ad4dd409420039 to your computer and use it in GitHub Desktop.
Cli command to create sarcasm/mocking formatted texrt
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
#!/usr/bin/env python3 | |
import sys | |
def sarcasmify(text): | |
new_text = '' | |
flip = True | |
for i in range(len(text)): | |
char = text[i] | |
if flip: | |
new_text += char.lower() | |
else: | |
new_text += char.upper() | |
# Only flip if the current char was an alpha character | |
if char.isalpha(): | |
flip = not flip | |
return new_text | |
if sys.stdin.isatty(): | |
text = input('Text: ') | |
else: | |
text = sys.stdin.read() | |
print(sarcasmify(text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment