Skip to content

Instantly share code, notes, and snippets.

@augustomen
Created February 10, 2016 21:57
Show Gist options
  • Save augustomen/193aedf7ac85ea122fae to your computer and use it in GitHub Desktop.
Save augustomen/193aedf7ac85ea122fae to your computer and use it in GitHub Desktop.
Gerador de palavra aleatória
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