ji-0630 / CodingTest

코딩테스트 연습 기록
0 stars 0 forks source link

모음 제거 #132

Closed ji-0630 closed 1 year ago

ji-0630 commented 1 year ago

문제 설명

image

ji-0630 commented 1 year ago

나의 풀이

def solution(my_string):
    answer = ''
    for i in my_string:
        if i in ['a', 'e', 'i', 'o', 'u']:
            continue
        else:
            answer += i

    return answer
ji-0630 commented 1 year ago

다른 사람의 풀이

첫 번째

def solution(my_string):
    return "".join([i for i in my_string if not(i in "aeiou")])

두 번째

def solution(my_string):
    vowels = ['a','e','i','o','u']
    for vowel in vowels:
        my_string = my_string.replace(vowel, '')
    return my_string