def translate(response):
"""Translates an English word into Pig Latin."""
# Initial lists and strings
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "y", "Y"]
consonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z", "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Z"]
consonant_string = ""
response = response.split()
for k, word in enumerate(response):
for i in vowels:
if word[0] == i:
word += "way"
response[k] = word
break
for x in range(len(word)):
if word[x] in vowels:
break
for i in consonants:
if word[x] == i:
consonant_string += i
word = word[len(consonant_string):]
word += consonant_string
word += "ay"
response[k] = word
return response
Hmm...okay, that worked, but now I have another problem. May just be my tiredness, but when I enter say "taco bell", the first word comes out correctly, but the second is changed to "lltbay". If I do bell on its own, it comes out fine. I'm guessing it's an error with "break" somewhere but I'm not sure where.