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 = Truelast = Falsei = 0while (i < len(word)):="" #traverse="" whole="">if word[i] in vowels: # if character in a word is vowelif last == False: # if last charcater was not vowelif flag == True: #check if first occurence of vowelword = word[0:i] + gib1 + word[i:len(word)] #add gibberish to the wordi = i + len(gib1) + 1flag = Falselast = Trueelse:word = word[0:i] + gib2 + word[i:len(word)] # if other than first occurence of voweli = i + len(gib2) + 1last = Trueelse:i = i + 1else: # if character is not vowellast = False # set last character was not voweli = 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()
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here