[Programmers] - 숫자 문자열과 영단어 (Level 1)
2021 카카오 채용연계형 인턴십
LEVEL : 1
def solution(s):
import re
new = s
dict = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
for num,char in enumerate(dict):
p = re.compile(char)
new = p.sub(str(num), new)
return int(new)
s = "one4seveneight"
num = '0'
char = 'zero'
p = re.compile(char)
solution(s)
1478
Comments