[Programmers] 숫자 문자열과 영단어

ironcat·2022년 3월 8일
0

알고리즘

목록 보기
3/17

알고리즘 문제풀이

문제 링크

def solution(s):
    words = {'zero': 0, 'one': 1, 'two': 2, 'three': 3,
          'four': 4, 'five': 5, 'six': 6, 'seven': 7,
          'eight': 8, 'nine': 9}
    
    tmp = s
    for key, value in words.items():
        tmp = tmp.replace(key, str(value))
            
    answer = int(tmp)
    return answer
profile
공부하는 블로그

0개의 댓글