for item in s:
if item == "r":
s = list(s)
posR = s.index("r")
while s[posR-1] == "a" or s[posR-1] == "e"\
or s[posR-1] == "i" or s[posR-1] == "o"\
or s[posR-1] == "u":
s[posR-1] = ""
在上面的代码中,程序检查字母“r”是否在字符串中(用变量's'表示,如果是r,则检查r之前的字母是否为元音,是否为元音被删除。例如
s = iterate
s = itrate
但是,如果字符串中有多个 'r',我该如何让程序执行此操作?IE
s = characters
s = chractrs