def solution(s):
lst = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
answer = s
for i in range(len(lst)):
if lst[i] in s:
answer = answer.replace(lst[i],f'{i}')
return int(answer)
num_dic = {"zero":"0", "one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine":"9"}
def solution(s):
answer = s
for key, value in num_dic.items():
answer = answer.replace(key, value)
return int(answer)
def solution(s):
words = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
for i in range(len(words)):
s = s.replace(words[i], str(i))
return int(s)
replace 함수를 쓰면 따로 for문 안돌려도 된다.