알고리즘 문제 풀이

[프로그래머스 - Python] 숫자 문자열과 영단어

김혠 2024. 8. 9. 21:31

문제 링크

 

최종 코드(코드링크)

def solution(s):
    arr = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    for i,c in enumerate(arr):
        s = s.replace(c,str(i))
    return int(s)

기본적인 문법만 알아도 풀 수 있는 간단한 문제였다 !