
author:多测师_王sir
def func(str):
'''
:param str: 传入一个字符串"My name is Shopline,and i am 2,0000 days old"
:return:
'''
result = []
s = str.split() #先进行分割为列表
for word in s:
if word[0] in "aeiou":#第一个字母在‘aeiou'中末尾加入‘hay'
temp1= word + "hay"
result.append(temp1) #['ishay', 'ihay', 'amhay', 'oldhay']
elif word[0] not in "aeiou": #第一个字母不是‘aeiou’,连续的辅音字母一起移动到单词末尾加入“ay”
temp =""
index = 0
temp += word[0]
for i in range(1,len(word)):
if word[i] not in "aeiouy":
temp += word[i] #把首个字母不在"aeiou"里面字符串进行拼接
index += 1
else:
break
#如果判断每个列表中的元素首个字母不在"aeiou"里面、index索引位置需要加上1、然后把temp挪到后面再加上ay字符串
result.append(word[index+1:] + temp + "ay")
print(result)
func("My name is Shopline,and i am 2,0000 days old")