Skip to content

Instantly share code, notes, and snippets.

@wjimenez5271
Created January 3, 2014 00:43
Show Gist options
  • Select an option

  • Save wjimenez5271/8230340 to your computer and use it in GitHub Desktop.

Select an option

Save wjimenez5271/8230340 to your computer and use it in GitHub Desktop.
pig_latin_translate.py
#define the suffix we'll use in pig latin
pyg = 'ay'
#ask for input of the word to translate
original = raw_input('Enter a word:')
#santize input and check to see if word starts with a vowel or consonant
if len(original) > 0 and original.isalpha():
original = original.lower()
print "you entered: " + original
if (original[0] == 'a' or original[0] == 'e' or original[0] == 'i' or original[0] =='u'):
new_word = (original + pyg)
print new_word
else:
word2 = original[1:]
new_word = word2 + original[0] + pyg
print new_word
else:
print 'empty, please supply a word to be translated'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment