Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- consonants = (66,67,68,70,71,72,74,75,76,77,78,\
- 80,81,82,83,84,86,87,88,89,90)
- vowels = (65,69,73,79,85)
- while True:
- try:
- letters = int(input("Enter a number: "))
- break
- except ValueError:
- print("That is not a valid entry.")
- tupword = []
- if random.randrange(1,3) == 1:
- consonant = 1
- else:
- consonant = 0
- while letters > 0:
- if consonant == 1:
- tupword.append(chr(random.choice(consonants)))
- consonant = 0
- letters -= 1
- else:
- tupword.append(chr(random.choice(vowels)))
- consonant = 1
- letters -= 1
- word = ''.join(str(v) for v in tupword)
- print(word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement