나의 풀이
def solution(s):
dic_alpha = {'zero':'0', 'one':'1', 'two':'2', 'three':'3', 'four':'4', 'five':'5', 'six':'6','seven':'7','eight':'8', 'nine':'9'}
for key,value in dic_alpha.items():
s=s.replace(key, value)
return int(s)
▶ replace( 변경할 문자, 대체문자)
▶ replace 메서드의 두 인자 모두 String 타입이 와야된다는 사실에 주의한다.
'프로그래머스(파이썬) > LV.1(파이썬)' 카테고리의 다른 글
모의고사 → 순환 %★ + for x, y in enumerate(answers)★ (0) | 2022.12.17 |
---|---|
삼총사→ 조합 + 삼중 for문 (0) | 2022.12.17 |
k번째 수-슬라이싱★★ (0) | 2022.12.17 |
문자열 내 마음대로 정렬하기→특이한 정렬과 유사★ (0) | 2022.12.17 |
[1차] 비밀지도→ OR연산 + rjust(자릿수, 숫자)★★ (0) | 2022.12.17 |