what should I add to make it reject a number? and ask the user to not enter a number by displaying "Syllable must only contain letters or a wildcard" def add_gibberish(word, gib1, gib2): vowels =...


what should I add to make it reject a number? and ask the user to not enter a number by displaying "Syllable must only contain letters or a wildcard"



def add_gibberish(word, gib1, gib2):
vowels = "AaEeIiOoUu"
flag = True
last = False
i = 0
while (i < len(word)):="" #traverse="" whole="">
if word[i] in vowels: # if character in a word is vowel
if last == False: # if last charcater was not vowel
if flag == True: #check if first occurence of vowel
word = word[0:i] + gib1 + word[i:len(word)] #add gibberish to the word
i = i + len(gib1) + 1
flag = False
last = True
else:
word = word[0:i] + gib2 + word[i:len(word)] # if other than first occurence of vowel
i = i + len(gib2) + 1
last = True
else:
i = i + 1
else: # if character is not vowel
last = False # set last character was not vowel
i = i + 1;

return word




def start():
gib1 = input("Enter first gibberish syllable: ")
gib2 = input("Enter second gibberish syllable: ")
word = input("Enter a word to translate: ")
new_word = add_gibberish(word, gib1, gib2)
print("Gibberish word is: ", end=" ")
print(new_word)
do_again()




def do_again():
print("Do you want to play again: 'y' for yes and 'n' for no ")
ans = input()
if (ans in "Yy"):
start()
elif (ans in "Nn"):
exit(0)
else:
print("Enter a valid input")
do_again()




print("Let's play a game. Give us a word and gibberish syllable. Using that we will translate your word to gibberish")
start()




Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here