• steps
    • ask user to input work in english
    • make sure the user entered a valid word
    • convert the word from english to pig latin
    • display the translation result
  • raw_input()accepts a string, prints it and waits for the user to type something and press enter
    • name = raw_input("What's your name?")
    • print name
  • isalpha() can be used to check that the user typed only alphabetical characters
    • and lalala.isalpha()
  • ay b c
    • pyg = 'ay'
    • first = word[0] <---- means the first letter of the word
      • add ay and first letter to the end of the string

syntax

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():

      • word = original.lower()
      • first = word[0]
      • new_word = word + first + pyg
      • new_word = new_word[1:len(new_word)]
      • print new_word

else:

      • print 'empty'
nov 29 2014 ∞
apr 19 2015 +