Skip to content

Instantly share code, notes, and snippets.

@Lubba-64
Created March 21, 2022 14:09
Show Gist options
  • Save Lubba-64/f4c5c73db199f50685164f9de8c0a212 to your computer and use it in GitHub Desktop.
Save Lubba-64/f4c5c73db199f50685164f9de8c0a212 to your computer and use it in GitHub Desktop.
import random
consonants = ['q','w','r','t','y','p','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m']
vowels = ['a','e','i','o','u']
app_is_running = True
def rand_in_list(List):
"""
Fetches a random element in a list.
"""
return List[random.randrange(0,len(List)-1)]
def gen_name() -> str:
name = ""
for i in range(14):
if random.randint(0,3) == 0 and i > 4:
break
else:
name += rand_in_list(consonants) + rand_in_list(vowels)
return name
num_names = int(input('Number of names to output: '))
names = '\n'.join([gen_name() for x in range(num_names)])
write_to_file = input("Write to file (y/n): ").lower() in ['yes','y','ok','true']
if write_to_file:
with open('names_generated.txt','wt') as f:
f.write(names)
else:
print(names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment