Python Programming Pig Latin is a language game in which English words are altered, usually by manipulating the position of the letters in words and/or adding suffixes/prefixes. Here are the rules so that you won't get lost in translation. 1. If a word starts with a consonant and a vowel, put the first letter of the word at the end of the word and add "ay." 2. If a word starts with two consonants move the two consonants to the end of the word and add "ay." 3. If a word starts with a vowel add the word "way" at the end of the word. Your task is: 1. To complete the piglatin_translate function. Input Format The input accepts phrases in string format. Constraints For simplicity, the input lines accept phrases that are in lower case and have no punctuations. These phrases only contain letters and spaces. Output Format The piglatin_translate method should return the translated version of the input phrase as a string. Sample Input 1 pig latin is hard to speak Sample Output 1 igpay atinlay isway ardhay otay eakspay Sample Input 2

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
100%

Python Problem (see pic)

What I have done (so far): pls help!

Template: 

# What I have done need help
vowels = ['a','e','i','o','u','A','E','I','O','U']
output=[]
def piglatin_translate(phrase):
    words = phrase.split()
    for i in words:
        l = list(i)
        if len(i)>1:
            if l[1] in vowels and l[0] not in vowels:
                l1=l[0]+'ay'
                l.pop(0)
                new=''.join(l)
                new = new+l1
                output.append(new)
                continue
            if l[0] not in vowels and l[1] not in vowels:
                n=l[0]+l[1]
                n+='ay'
                l.pop(0)
                l.pop(0)
                n1=''.join(l)
                n1+=n
                output.append(n1)
                continue
        if l[0] in vowels:
            m=''.join(l)
            m+='way'
            output.append(m)
            continue
        return(''.join(output))

if __name__ == "__main__":
    input_line = str(input())
    print(piglatin_translate(input_line))
Python Programming
Pig Latin is a language game in which English words are altered, usually by manipulating the position of
the letters in words and/or adding suffixes/prefixes. Here are the rules so that you won't get lost in
translation.
1. If a word starts with a consonant and a vowel, put the first letter of the word at the end of the word and
add "ay."
2. If a word starts with two consonants move the twO consonants to the end of the word and add "ay."
3. If a word starts with a vowel add the word "way" at the end of the word.
Your task is:
1. To complete the piglatin_translate function.
Input Format
The input accepts phrases in string format.
Constraints
For simplicity, the input lines accept phrases that are in lower case and have no punctuations. These
phrases only contain letters and spaces.
Output Format
The piglatin_translate method should return the translated version of the input phrase as a string.
Sample Input 1
pig latin is hard to speak
Sample Output 1
igpay atinlay isway ardhay otay eakspay
Sample Input 2
my name is a very long string
Sample Output 2
myay amenay isway away eryvay onglay ringstay
# Template
3 vdef piglatin_translate (phrase):
4.
""Translates a phrase into Pig Latin."""
"-_main__":
input line str(input())
print (piglatin_translate (input line))
6 vif name_ ==
11
8
Transcribed Image Text:Python Programming Pig Latin is a language game in which English words are altered, usually by manipulating the position of the letters in words and/or adding suffixes/prefixes. Here are the rules so that you won't get lost in translation. 1. If a word starts with a consonant and a vowel, put the first letter of the word at the end of the word and add "ay." 2. If a word starts with two consonants move the twO consonants to the end of the word and add "ay." 3. If a word starts with a vowel add the word "way" at the end of the word. Your task is: 1. To complete the piglatin_translate function. Input Format The input accepts phrases in string format. Constraints For simplicity, the input lines accept phrases that are in lower case and have no punctuations. These phrases only contain letters and spaces. Output Format The piglatin_translate method should return the translated version of the input phrase as a string. Sample Input 1 pig latin is hard to speak Sample Output 1 igpay atinlay isway ardhay otay eakspay Sample Input 2 my name is a very long string Sample Output 2 myay amenay isway away eryvay onglay ringstay # Template 3 vdef piglatin_translate (phrase): 4. ""Translates a phrase into Pig Latin.""" "-_main__": input line str(input()) print (piglatin_translate (input line)) 6 vif name_ == 11 8
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Introduction to Coding
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT