PRACTICE PROJECT SOLUTIONS

image

This appendix provides the solutions to the practice projects in each chapter. Digital versions are available on the book’s website at https://www.nostarch.com/impracticalpython/.

Chapter 1: Silly Name Generator

Pig Latin

pig_Latin_practice.py

"""Turn a word into its Pig Latin equivalent."""import sysVOWELS = 'aeiouy'while True:    word = input("Type a word and get its Pig Latin translation: ")    if word[0] in VOWELS:        pig_Latin = word + 'way'    else:        pig_Latin = word[1:] + word[0] + 'ay'    print()    print("{}".format(pig_Latin), file=sys.stderr)    try_again = input("\n\nTry again? (Press Enter else ...

Get Impractical Python Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.