This is a basic name generator I just wrote and want some feedback. It basically chooses between a vowel or a consonant and appends it to a string. Note that it never puts two vowels or two consonants directly together, as it checks for that.
import random
vowels = ['a', 'e', 'i', 'o', 'u']
consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'x', 'y', 'z']
def generate_name(length):
if length <= 0:
return False
full_syl = ''
for i in range(length):
decision = random.choice(('consonant', 'vowel'))
if full_syl[-1:].lower() in vowels:
decision = 'consonant'
if full_syl[-1:].lower() in consonants:
decision = 'vowel'
if decision == 'consonant':
syl_choice = random.choice(consonants)
else:
syl_choice = random.choice(vowels)
if full_syl == '':
full_syl += syl_choice.upper()
else:
full_syl += syl_choice
return full_syl
for i in range(100):
length = random.randint(3, 10)
print(generate_name(length))