标签:turn nal print join head rdl rip pig strip
正常的
def pig_it():
word = ‘Pig latin is cool ‘
wordList = word.split()
re = ‘‘
for item in wordList:
if item.isalpha():
head = item[1:]
ass = item[0]+‘ay‘
temp = head+ass+‘ ‘
else:
temp = item+‘‘
re += temp
re.strip()
print(re)
骚一点的
def pig_it_final():
word = ‘Pig latin is cool !‘
print(‘ ‘.join([item[1:] +item[0]+‘ay‘ if item.isalpha() else item for item in word.split()]))
return ‘ ‘.join([item[1:] +item[0]+‘ay‘ if item.isalpha() else item for item in word.split()])
if __name__ == ‘__main__‘:
pig_it_final()
标签:turn nal print join head rdl rip pig strip
原文地址:http://www.cnblogs.com/sayHello2World/p/7137955.html