Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- consonant = ['b','c','d','f','g','h','l','j','k','m','n','p','q','r','s','t','w','v','x','y','z']
- #list of consanants
- vowel = ['a','e','i','o','u']
- #list of vowels
- typeLetter = random.randint(0,1)
- #Chooses whether the first letter is a vowel or consonant
- letter = 1
- #represents the position of the letter
- word=""
- #represents the word
- if typeLetter == 0:
- nextLetter = consonant[random.randint(0,20)]
- #makes the next letter a consonant
- word+=nextLetter
- elif typeLetter == 1:
- nextLetter = vowel[random.randint(0,4)]
- #makes the next letter a vowel
- word+=nextLetter
- while letter<4:
- #means the word will not have more than 4 letters
- if typeLetter==0:
- if word[-1] == "q":
- word+="u"
- #makes it if the previous letter was q, make the next letter u
- else:
- word+=vowel[random.randint(0,4)]
- #If previous letter was not a q, make the next letter a random vowel
- elif typeLetter==1:
- word+=consonant[random.randint(0,20)]
- #makes the next letter a random consonant
- if typeLetter==0:
- typeLetter+=1
- #makes the next letter consonant
- elif typeLetter==1:
- typeLetter-=1
- #makes the next letter a vowel
- letter+=1
- #moves on to the next letter in the sequence
- print (word)
- #Should be a 4 letter word with all vowels being followed by consonants and vice versa, as well as q always being followed by u
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement