Lab 4

In this lab we introduce Pyg Latin to Python and crate a program which translates English words into Pig Latin.

 

Code

pyg = 'ay'
original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
    if first == "a" or first == "e" or first == "u" or first == "o" or first == "i":
        new_word = word + pyg
        print new_word
    else:
        changed_word = word[1:]
        new_word = changed_word + first + pyg
        print new_word
else:
    print 'empty'

Lab 4 pyg

Leave a Reply

Your email address will not be published. Required fields are marked *