Coverage for e06_pig_latin_sentence.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python3
2"""Solution to chapter 2, exercise 6: pl_sentence"""
5def pl_sentence():
6 """Ask the user to enter lowercase, unpuncutated words. Print the sentence, translated into Pig Latin."""
7 sentence = input("Enter a sentence: ")
9 output = []
10 for word in sentence.split():
11 if word[0] in 'aeiou':
12 output.append(f"{word}way")
13 else:
14 output.append(f"{word[1:]}{word[0]}ay")
16 print(' '.join(output))