Removing items for a list using a loop in Python

前端 未结 5 1208
深忆病人
深忆病人 2020-12-12 00:17

I am very new to programming in general and have started with Python. I am working through various problems to try and better my understanding.

I am trying to defin

5条回答
  •  渐次进展
    2020-12-12 01:15

    You can use a list comp:

    def anti_vowel(text):
        vowels = 'aeiouAEIOU'
        return "".join([x for x in text if x not in vowels])
    print anti_vowel("Hey look words!")
    Hy lk wrds!
    

    The list comprehension filters the vowels from the words.

提交回复
热议问题