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 word in response:
for i in vowels:
if word[0] == i:
word += "way"
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"
return response
An assignment for school was to make a program which would take an English word and translate it to the fake language of Pig Latin. I'm now trying to make it so that it can translate an entire sentence, one word at a time. Because of this, a lot of stuff comes copy and pasted from the original and may not make sense. However, I can not figure out what's wrong here. It just returns the list of words unaltered.