나는 이렇게 학습한다/Algorithm & SQL

Disemvowel Trolls

daco2020 2022. 5. 5. 00:06
반응형

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:

1. Check if there is a vowel among the characters of string.
2. Returns all characters except vowels.

 

def disemvowel(string_):
    return ''.join([string_[i] for i, v in enumerate(string_.lower()) if v not in "aeiou"])

 

 

 

반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

Even numbers in an array  (0) 2022.05.06
Number of People in the Bus  (0) 2022.05.05
Categorize New Member  (0) 2022.05.03
Are You Playing Banjo?  (0) 2022.05.02
Find the vowels  (0) 2022.05.01