Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python: 13. Pig Latin Write a program that accepts a sentence as input and converts each word to Pig Latin. In one version, to

In Python:

13. Pig Latin Write a program that accepts a sentence as input and converts each word to "Pig Latin." In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then, you append the string "ay" to the word.

I am having a singular issue with my code, and that is the output is not correctly spacing out the words once theyre converted.

My code is as follows:

sentence = input("Please enter a sentence/phrase that you want converted into Pig Latin:")

words = sentence.split()

for i in range (len(words)):

pig_latin = words [i][1:] + words [i][0]

pig_latin += "ay"

words[i] = pig_latin

pig_latin_phrase = "".join(words)

print(pig_latin_phrase)

The output of a phrase looks like this:

image text in transcribed

What can i add to this code to help keep the spacing between the words?

Please enter a sentence/phrase that you want converted into Pig Latin: one fish, two fish, red fish, blue fish neoayish, faywotayish, fayedrayish, fayluebayishfay

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions