Lab 4: PigLatin

Lab Description:

In this lab, I used the Python program to create a program that translates into Pyg Latin. In this project, I will put together all of the Python skills I have learn so far including strings manipulation and branching. In this project, I have build a Pyg Latin translator, which is known as Pig Latin for Python programmers.

Code:

pyg = ‘ay’

original = raw_input(‘Enter a word:’)
word = original.lower()
first = word[0]
if len(original) > 0 and original.isalpha():
if (first == “a” or first == “e” or first == “i” or first == “o” or first == “u”):
new_word = word + pyg
print (new_word)
else:
new_word = word[1:] + word[0] + pyg
print (new_word)
else:
print (’empty’)

ScreenShots:

Lab4 Pig Latin

Leave a Reply

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