[7 kyu] Disemvowel Trolls

Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls’ comments, neutralizing the threat.

Your task is to write a function that takes a string and return a new string with all vowels removed. For example, the string “This website is for losers LOL!” would become “Ths wbst s fr lsrs LL!”.

Note:
for this kata y isn’t considered a vowel.

Solution :

def disemvowel(string):
    new_string = ""
    comment_section = ["a","i","u","e","o","A","I","U","E","O"]
    for letter in string:
        if letter not in comment_section:
            new_string += letter
        else:
            new_string = new_string
            
    return new_string
发布了16 篇原创文章 · 获赞 0 · 访问量 48

猜你喜欢

转载自blog.csdn.net/HM_773_220/article/details/104764313
7
今日推荐