Lab Description:
In this lab I had to build a Pig Latin translator. Pig Latin takes the first character of a word and put it on the end of the word. Then the translator adds “ay” to the end after it moves the first character to the end. In the lab I choose a word that starts with a vowel and used a for loop to check if the word actually started with a vowel. And I did the same with a constant word.
Source Code:
pyg = ‘ay’
original = raw_input(‘Enter a word:’)
if len(original) > 0 and original.isalpha():
print ‘original’
else:
print ’empty’
original = ‘Enter a word:’
original.lower()
word = original.lower()
first = word[0]
vowel = (‘a’,’e’,’i’,’o’,’u’)
if first == vowel:
print ‘vowel’
else:
print ‘constant’
new_word = word[1:] + first + pyg