Created
March 23, 2015 22:12
-
-
Save mjdarby/ae1aa94b6b3c8c29d401 to your computer and use it in GitHub Desktop.
dumb.py - A script for generating vaguely-readable anagrams ... as long as you don't use punctuation.
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
#!/usr/bin/python | |
# What's that? You like to use punctuation? Forget about it. | |
import sys | |
import random | |
if __name__ == "__main__": | |
string = sys.argv[1:] | |
anagrammed = [] | |
for element in string: | |
if len(element) > 1: | |
first_letter = element[0] | |
last_letter = element[-1] | |
element = list(element[1:-1]) | |
random.shuffle(element) | |
element = first_letter + "".join(element) + last_letter | |
anagrammed.append(element) | |
anagrammed = " ".join(anagrammed) | |
print(anagrammed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment