Advertisement
aricleather

Pronouncable Name Generator

May 1st, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import random
  2. consonants = (66,67,68,70,71,72,74,75,76,77,78,\
  3. 80,81,82,83,84,86,87,88,89,90)
  4. vowels = (65,69,73,79,85)
  5. while True:
  6.     try:
  7.         letters = int(input("Enter a number: "))
  8.         break
  9.     except ValueError:
  10.         print("That is not a valid entry.")
  11. tupword = []
  12. if random.randrange(1,3) == 1:
  13.     consonant = 1
  14. else:
  15.     consonant = 0
  16. while letters > 0:
  17.     if consonant == 1:
  18.         tupword.append(chr(random.choice(consonants)))
  19.         consonant = 0
  20.         letters  -= 1
  21.     else:
  22.         tupword.append(chr(random.choice(vowels)))
  23.         consonant = 1
  24.         letters -= 1
  25. word = ''.join(str(v) for v in tupword)
  26. print(word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement