https://programmers.co.kr/learn/courses/30/lessons/81301
def solution(s):
temp = ""
answer = ""
d = {'zero':'0', 'one':'1', 'two':'2', 'three':'3', 'four':'4', 'five':'5', 'six':'6', 'seven':'7', 'eight':'8', 'nine':'9'}
for i in s:
if i.isnumeric():
temp = ''
answer += i
continue
else :
temp += i
if temp in d:
answer += d[temp]
temp = ''
answer += d[temp] if temp in d else ''
return int(answer)
평소에 switch문보다 if else 문을 선호해서 잘 안쓰다보니 몰랐는데
파이썬에 switch case가 없다는걸 처음알았다.
if else로 쭉 비교하는것보다 dict로 만들면 O(1)로 처리가 가능하기에 더 효율적일것 같다는 생각이 들어서 이렇게 처리했다.