Last active
August 28, 2024 11:16
-
-
Save noxan/5845351 to your computer and use it in GitHub Desktop.
A simple python script to generate random names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import random | |
import string | |
import sys | |
VOWELS = "aeiou" | |
CONSONANTS = "".join(set(string.ascii_lowercase) - set(VOWELS)) | |
def generate_word(length): | |
word = "" | |
for i in range(length): | |
if i % 2 == 0: | |
word += random.choice(CONSONANTS) | |
else: | |
word += random.choice(VOWELS) | |
return word | |
if __name__ == "__main__": | |
try: | |
count = int(sys.argv[1]) | |
except: | |
count = 5 | |
try: | |
length = int(sys.argv[2]) | |
except: | |
length = 6 | |
for i in range(count): | |
print(generate_word(length)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment