首页 > 代码库 > for的骚用法

for的骚用法

正常的
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()

for的骚用法