Python反元音计划

时间:2015-03-01 01:39:18

标签: python

我在codeacademy上学习Python并且我一直坚持一个程序:

  

定义一个名为anti_vowel的函数,该函数将一个字符串text作为输入,并返回删除了所有元音的文本。
  例如:anti_vowel("Hey You!")应该返回"Hy Y!"   不要把Y算作元音   确保删除小写和大写元音。

我创建了该程序,但我没有看到任何错误的方法,但我收到此错误代码:

  

哎呀,再试一次。您的功能在anti_vowel("Hey look Words!")上失败。它应返回"Hy lk Words!"时返回"Hy lk Wrds!"。*

谁能告诉我我做错了什么?这是代码:

def anti_vowel(text):
    newText = ""
    tList = []
    for char in text:
        tList.append(char)
    for item in tList:
        if item in "aeiouAEIOU":
            tList.remove(item)
    for thing in tList:
        newText += thing
    return newText

0 个答案:

没有答案