Hide keyboard shortcuts

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 5: pig_latin""" 

3 

4 

5def pig_latin(): 

6 """Ask the user for a lowercase, unpunctuated word, and print the translation into Pig Latin.""" 

7 word = input("Enter a word: ") 

8 

9 if word[0] in 'aeiou': 

10 print(f'{word}way') 

11 else: 

12 print(f'{word[1:]}{word[0]}ay')