나의 개발일지

[프로그래머스] Lv.1 숫자 문자열과 영단어 [Python, 파이썬] KAKAO 본문

프로그래머스

[프로그래머스] Lv.1 숫자 문자열과 영단어 [Python, 파이썬] KAKAO

YoonJuHan 2023. 9. 22. 18:05
def solution(s):
    
    d = {"zero" : "0", 
         "one" : "1",
         "two" : "2",
         "three" : "3",
         "four" : "4",
         "five" : "5",
         "six" : "6",
         "seven" : "7",
         "eight" : "8",
         "nine" : "9",
         }

    for i in d:
        if i in s:
            s = s.replace(i, d[i])

    return int(s)


print(solution("one4seveneight"))
Comments