[알고리즘/프로그래머스] KAKAO - 숫자 문자열과 영단어(python)

유현민·2022년 5월 9일
0

알고리즘

목록 보기
178/253

replace함수를 사용해서 풀었습니다.

def solution(s):
    w = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

    for idx, k in enumerate(w):
        s = s.replace(k, str(idx))

    return int(s)


print(solution("one4seveneight"))
profile
smilegate megaport infra

0개의 댓글