Created
February 10, 2016 21:57
-
-
Save augustomen/193aedf7ac85ea122fae to your computer and use it in GitHub Desktop.
Gerador de palavra aleatória
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 random | |
consonants = 'bcdfghjlmnpqrstvxz' | |
vowels = 'aeiou' | |
def new_word(syllables=None): | |
if syllables is None: | |
syllables = random.randint(2, 5) | |
result = '' | |
for i in range(syllables): | |
consonant = random.choice(consonants) | |
this_vowels = vowels | |
if consonant == 'q': | |
consonant += 'u' | |
this_vowels = 'aeio' | |
result += consonant + random.choice(this_vowels) | |
if i > 0 and result[-2] in 'bp' and random.randint(0, 5) == 0: | |
result = result[:-2] + 'm' + result[-2:] | |
if i > 0 and result[-2] in 'cglrst' and random.randint(0, 5) == 0: | |
result = result[:-2] + 'n' + result[-2:] | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment