Skip to content

Instantly share code, notes, and snippets.

@Syncrossus
Created September 6, 2021 11:34
Show Gist options
  • Save Syncrossus/91e8c1aeef098e8df2ccb6aedc233349 to your computer and use it in GitHub Desktop.
Save Syncrossus/91e8c1aeef098e8df2ccb6aedc233349 to your computer and use it in GitHub Desktop.
This function attempts to generate mostly pronounceable character combinations to create random names.
import string
import random
vowels = 'aeiouy'
consonants = list(set(string.ascii_lowercase).difference(set(vowels)))
def generate_name():
name = ''
consecutive_consonants = 0
for i in range(random.randint(3, 10)):
new_letter = random.choice(string.ascii_lowercase)
if new_letter in consonants:
consecutive_consonants += 1
if consecutive_consonants > 2:
new_letter = random.choice(vowels)
consecutive_consonants = 0
name = name + new_letter
return name
for i in range(20):
print(generate_name())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment