Skip to content

Instantly share code, notes, and snippets.

@RandoNandoz
Last active June 3, 2021 22:55
Show Gist options
  • Save RandoNandoz/5605b41dc8cf4f86a9b4a6aff1fee78f to your computer and use it in GitHub Desktop.
Save RandoNandoz/5605b41dc8cf4f86a9b4a6aff1fee78f to your computer and use it in GitHub Desktop.
"""
Python script that automatically randomly capitalizes text from input.
"""
import random
def main():
to_shiverify = input("Text to shiverify: ")
print("\n" + shiverify(to_shiverify))
def shiverify(mucho_texto: str) -> str:
sentences = mucho_texto.split(".")
new_paragraph: list[str] = []
for sentence in sentences:
to_capitalize_word_numbers: list[int] = []
new_sentence: list[str] = []
sentence_broken = sentence.split(" ")
for _ in sentence_broken:
to_capitalize_word_numbers.append(random.randint(0, len(sentence)))
for word in enumerate(sentence_broken):
if word[0] == len(sentence_broken) - 1:
new_sentence.append(word[1] + ".")
elif word[0] in to_capitalize_word_numbers:
new_sentence.append(f"**{word[1].upper()}**")
else:
new_sentence.append(word[1])
for word in new_sentence:
new_paragraph.append(word + " ")
return "".join(new_paragraph) + "🐊"
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment