반응형
https://programmers.co.kr/learn/courses/30/lessons/81301?language=python3
코딩테스트 연습 - 숫자 문자열과 영단어
네오와 프로도가 숫자놀이를 하고 있습니다. 네오가 프로도에게 숫자를 건넬 때 일부 자릿수를 영단어로 바꾼 카드를 건네주면 프로도는 원래 숫자를 찾는 게임입니다. 다음은 숫자의 일부 자
programmers.co.kr


This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(s): | |
table = { | |
"zero" : "0", | |
"one" : "1", | |
"two" : "2", | |
"three" : "3", | |
"four" : "4", | |
"five" : "5", | |
"six" : "6", | |
"seven" : "7", | |
"eight" : "8", | |
"nine" : "9" | |
} | |
for key, value in table.items(): | |
s = s.replace(key, value) | |
return int(s) |
반응형
'프로그래밍 > 코딩테스트 문제풀이' 카테고리의 다른 글
[Python] 프로그래머스. 2021 카카오 인턴 - 표 편집 (Level 3) (0) | 2021.07.24 |
---|---|
[Python] 프로그래머스. 2021 카카오 인턴 - 거리두기 확인하기 (Level 2) (0) | 2021.07.12 |
[Python] 프로그래머스. 스킬트리 (Level 2) (0) | 2021.03.01 |
[Python] 프로그래머스. 2021 카카오 recruit - 광고 삽입 (Level 3) (0) | 2021.02.22 |
[Python] 프로그래머스. 2021 카카오 recruit - 순위 검색 (Level 2) (0) | 2021.02.08 |