https://school.programmers.co.kr/learn/courses/30/lessons/81301?language=python3
def solution(s):
answer = ''
num_dic = {"zero":0, "one": 1, "two":2, "three":3, "four":4, "five":5, "six":6, "seven":7, "eight":8, "nine":9}
temp = []
j = 0
for i, nums in enumerate(s):
if nums.isnumeric() == True:
answer += str(nums)
j=i+1
elif s[j:i+1] in num_dic.keys():
answer += str(num_dic[s[j:i+1]])
j=i+1
return int(answer)
'Coding Test > 프로그래머스' 카테고리의 다른 글
[Level 2] / [Python] N-Queen (0) | 2022.10.19 |
---|---|
[Level 2] / [Python] 후보키 (0) | 2022.10.18 |
[Level 1] / [Python] K번째 수 (0) | 2022.10.14 |
[Level 1] / [Python] 문자열 내 마음대로 정렬하기 (0) | 2022.10.14 |
[Level 1] / [Python] 최소직사각형 (0) | 2022.10.14 |