此功能旨在删除字符串中的所有元音,但由于某些原因,它还会删除元音后的字母。
def anti_vowel(text):
letters = []
for letter in text:
letters.append(letter)
final = ""
for letter in letters:
if letter == "A" or letter == "a" or letter == "O" or letter == "o" or letter == "U" or letter == "u" or letter == "I" or letter == "i" or letter == "E" or letter == "e":
letters.remove(letter)
else:
final += letter
return final
例如,如果您输入“ Hello this is me”,则输出为“ Hlth m”(如果空格位于元音之后,它将删除空格),但是我希望输出为“ Hll ths s m”