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 word 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()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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 word
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()

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY