我正在尝试编写一个函数,以消除给定字符串中的元音字母,但它似乎没有按照预期的方式运行...
def anti_vowel(text):
for c in text:
if c in "aeiouAEIOU":
no_vowel = text.replace(c, '')
return no_vowel
print(anti_vowel('Hello World')
所以不是打印输出
Hll Wrld
它打印输出
Hell Wrld
感谢您(提前)的帮助。
no_vowel
定义在哪里? - Christian Dean