PigLatin

Lab descripition: In this lab, Pig latin was used. The code are translated to each new variable. First, we are to set original to input, it needs to be set into new word. In this exercise, we used vowels and consonant. We constantly use if and len that we had used in previous labs.

Souce Code:

pyg = ‘ay’

original = raw_input(‘Enter a word:’)

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

lab 5lab 4Screenshot:

Leave a Reply