Jordan B.

asked • 09/22/17

Python translating question

So I need to create a program that can translate sentences to Pig Latin. If the word begins with a vowel, the I need to append “way” to the end of the word. If the word begins with a consonant, remove all consonants from the beginning of the word
and append them to the end of the word. Then, append “ay” to the end of the word.
 
 
The initial code I was given was this:
 
VOWELS = "aeiou"
word = input("Enter a word ('quit' to quit): ")

# Error message used in Mimir test
#print("Can't convert empty string. Try again.")
 
 
I'm very confused on how to go about this. Everything I've tried so far has failed. 

1 Expert Answer

By:

Andy C. answered • 09/23/17

Tutor
4.9 (27)

Math/Physics Tutor

Andy C.

You also have to consider the case where the word begins with a double consonant.
Then both consonants get pushed to the back before appending the suffix ay
 
Ex The quick brown fox jumped over the lazy dogs.
 
  The ickquay ownbray oxfay umpedjay overay the azylay ogsday.
 
  This is addressed in the nested switch in Translate();
Report

09/23/17

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.