📍문제 설명
네오와 프로도가 숫자놀이를 하고 있습니다. 네오가 프로도에게 숫자를 건넬 때 일부 자릿수를 영단어로 바꾼 카드를 건네주면 프로도는 원래 숫자를 찾는 게임입니다.
📍입출력값
s | result |
---|---|
"one4seveneight" | 1478 |
"23four5six7" | 234567 |
"2three45sixseven" | 234567 |
"123" | 123 |
👉숫자는 숫자 그대로 출력, 영어는 숫자로 변경하여 출력
📍내 답안
def solution(s):
answer = s
num_dict ={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine'}
for i in num_dict.items():
answer = answer.replace(i[1], str(i[0]))
return int(answer)