Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I complete this function in python 3? def simple_pig_latin(input, sep= , end=.): Accept a string input, which might include multiple words separated by

How do I complete this function in python 3?

def simple_pig_latin(input, sep=" ", end="."): Accept a string input, which might include multiple words separated by a separator sep and perform the following steps: o Find the list of words (Note: words are just zero or more characters separated by a symbol. So, depending on the separator ' ' or 'a..b' could be a word.). o Inspect every word and apply the following conversions: if the word starts with a non-letter or contains no characters, do nothing to it if the word starts with a vowel, add 'way' to the end if the word starts with a consonant, place the first letter at the end and add 'ay' o Reassemble the words back into one string and return it, making sure a single sep is padded between any two neighboring words and the final string ends with end. o Assume: the input does not have any capital letters o Go ahead and use string methods like .join(), .split() Examples: o simple_pig_latin("i like this") 'iway ikelay histay.' # default sep(space) and end(dot) o simple_pig_latin("i like this", sep='.') 'i like thisway.' # separator is dot, so whole thing is a single word o simple_pig_latin("i-like-this","-") 'iway-ikelay-histay.' # sep is '-' and default end(dot) o simple_pig_latin("i.like.this",sep='.',end='!') 'iway.ikelay.histay!' # sep is '.' and end is '!' o simple_pig_latin(".") '..' # only word is '.', so do nothing to it and add a '.' to the end

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

Define misclassification error.

Answered: 1 week ago

Question

3. Existing organizations and programs constrain behavior.

Answered: 1 week ago