Skip to content

Instantly share code, notes, and snippets.

@blanboom
Created September 13, 2013 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blanboom/6549458 to your computer and use it in GitHub Desktop.
Save blanboom/6549458 to your computer and use it in GitHub Desktop.
PygLatin:CodeCademy 上的一个 Python 作业
# PygLatin Convertor
# by Blanboom
# 2013-9-13 Programmer's Day
# http://www.codecademy.com/zh/tracks/python
# Welcome message
print "Welcome to PygLatin convertor"
# The letters which should be added to the end of the word
pyg = 'ay'
# Input a word
original = raw_input('Enter a word:')
# Check if it is a real word
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0] # The first letter of the word
# Check if the first letter is a vowel
if 'a' == first or 'e' == first or 'i' == first or 'o' == first or 'u' == first:
new_word = word + pyg
print new_word
else:
word_len = len(word)
new_word = word[1:word_len] + first + pyg
print new_word
else:
print 'empty'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment