티스토리 뷰
https://programmers.co.kr/learn/courses/30/lessons/81301
코딩테스트 연습 - 숫자 문자열과 영단어
네오와 프로도가 숫자놀이를 하고 있습니다. 네오가 프로도에게 숫자를 건넬 때 일부 자릿수를 영단어로 바꾼 카드를 건네주면 프로도는 원래 숫자를 찾는 게임입니다. 다음은 숫자의 일부 자
programmers.co.kr
def solution(s):
answer = ''
eng = { 'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5',
'six': '6', 'seven': '7', 'eight': '8', 'nine': '9', 'zero': '0' }
num = ''
for word in s:
if word.isdigit():
answer += word
else:
num += word
if num in eng.keys():
answer += eng[num]
num = ''
return int(answer)
'Algorithm > Programmers' 카테고리의 다른 글
| [프로그래머스] 행렬 테두리 회전하기 - Python (0) | 2021.08.05 |
|---|---|
| [프로그래머스] 이진 탐색 - Python (0) | 2021.08.04 |
| [프로그래머스] 순위 검색 - Python (0) | 2021.07.30 |
| [프로그래머스] 이진 변환 반복하기 - Python (0) | 2021.04.20 |
| [프로그래머스] 거스름돈 - Python (0) | 2021.04.15 |
