Hi, I am trying to make a pig latin function in Python, which takes in a word and returns its pig latin translation. You can convert an English word into Pig Latin by moving all the consonants up to the first vowel to the end of the word and then appending "ay", e.g 'hello' becomes 'ellohay'.
This is my code:
def pig_latin(word):
""" Returns the pig latin translation of a word. """
i=0
new_word = word
vowel = ["a", "e","i","o","u"]
while word not in vowel:
word[i] = consonant
new_word = new_word[(i+1):] + consonant
i+=1
final_word = new_word + "ay"
return final_word
When I run it, it gives: NameError: name 'consonant' is not defined
I would really appreciate help regarding this.
Thank you![/i]
This is my code:
def pig_latin(word):
""" Returns the pig latin translation of a word. """
i=0
new_word = word
vowel = ["a", "e","i","o","u"]
while word not in vowel:
word[i] = consonant
new_word = new_word[(i+1):] + consonant
i+=1
final_word = new_word + "ay"
return final_word
When I run it, it gives: NameError: name 'consonant' is not defined
I would really appreciate help regarding this.
Thank you![/i]