Last active
December 22, 2015 22:39
-
-
Save fredrik/6541286 to your computer and use it in GitHub Desktop.
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
import itertools | |
import random | |
from string import ascii_lowercase as alphabet | |
vowels = ['a', 'e', 'i', 'o', 'u', 'y'] | |
consonants = list(set(alphabet) - set(vowels)) | |
def random_pronouncable_string(length): | |
c = (random.choice(consonants) for _ in xrange(length/2)) | |
v = (random.choice(vowels) for _ in xrange(length/2)) | |
return "".join(itertools.chain.from_iterable(zip(c, v))) | |
if __name__ == '__main__': | |
print random_pronouncable_string(4) | |
print random_pronouncable_string(8) | |
print random_pronouncable_string(16) | |
# => | |
# cogo | |
# zujowuqu | |
# pitaveweryhafafe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment