python删除元音不工作

时间:2017-07-13 09:29:46

标签: python

所以我一直试图从python中的Word中删除元音。根据编程逻辑,它应该做得很好。找不到问题。

def disemvowel(word):
    b = ['a', 'e', 'i', 'o', 'u']
    try:
        a = list(word)
    except ValueError:
        print("{} is not a word.".format(word))
    else:
        for words in a:
            for vowels in b:
                if words.lower() == vowels:
                    a.remove(words)
        word = ", ".join(a)
    return word


m = input("Enter word:")
print(disemvowel(m))

0 个答案:

没有答案