링크: https://school.programmers.co.kr/learn/courses/30/lessons/81301
유형: 구현
난이도: Lv.1
스스로 풀었는가? ✅
특이사항: 2021 카카오 채용연계형 인턴십 문제
def solution(s):
answer = s
digit_eng_dict = {
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9
}
for key in digit_eng_dict.keys():
answer = answer.replace(key, str(digit_eng_dict.get(key)))
return int(answer)
dict.keys()
대신 dict.items()
을 이용하면 쉽게 key와 value 값을 가져올 수 있다.[ktb-algorithm-study] 1주차