Skip to main content
Post Undeleted by Vogel612, Der Kommissar, 200_success
Post Deleted by das
edited tags
Link
200_success
  • 145.7k
  • 22
  • 191
  • 481
edited tags
Link
Mast
  • 13.9k
  • 12
  • 57
  • 128

Python Name Generatorname generator

added 1 character in body
Source Link
Tunaki
  • 9.3k
  • 1
  • 31
  • 46

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 cononantsconsonants 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))

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 cononants 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))

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))
Source Link
das
  • 41
  • 1
  • 4
Loading