python PygLatin:CodeCademy上的一个Python作业

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 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'

以上是关于python PygLatin:CodeCademy上的一个Python作业的主要内容,如果未能解决你的问题,请参考以下文章

代写python,代写python编程,python代写,python编程代写,留学生python代写

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍