Last active
April 10, 2019 02:46
-
-
Save wrouesnel/121f021c81de44bd774d24930b6c2807 to your computer and use it in GitHub Desktop.
Just a little Python function which scrambles words like that first and last letter are all you need meme.
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
from random import SystemRandom | |
rand = SystemRandom() | |
def scrambler(txt): | |
"""Disprover for that meme about letter ordering in English.""" | |
words = txt.split(" ") | |
result_words = [] | |
for word in words: | |
shuffled = [c for c in word[1:-1]] | |
rand.shuffle(shuffled) | |
result_word = word[0] + "".join(shuffled) + word[-1] | |
result_words.append(result_word) | |
return " ".join(result_words) | |
print(scrambler("""This meme isn't true and the examples given always use a relatively simple | |
sentence with simple composition. There's just not much mix up in short words, | |
whereas once you start extending it to longer words or more complicated structures things get unintelligble fast.""")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment