Notice
Recent Posts
Recent Comments
Link
나의 개발일지
[프로그래머스] Lv.1 숫자 문자열과 영단어 [Python, 파이썬] KAKAO 본문
- 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/81301
- dictionary, replace 활용
def solution(s):
d = {"zero" : "0",
"one" : "1",
"two" : "2",
"three" : "3",
"four" : "4",
"five" : "5",
"six" : "6",
"seven" : "7",
"eight" : "8",
"nine" : "9",
}
for i in d:
if i in s:
s = s.replace(i, d[i])
return int(s)
print(solution("one4seveneight"))
'프로그래머스' 카테고리의 다른 글
[프로그래머스] Lv.2 [1차] 뉴스 클러스터링 [Python, 파이썬] KAKAO (0) | 2023.09.24 |
---|---|
[프로그래머스] Lv.1 [1차] 비밀지도 [Python, 파이썬] KAKAO (0) | 2023.09.22 |
[프로그래머스] Lv.3 헤비 유저가 소유한 장소 [Oracle, 오라클] (0) | 2023.09.22 |
[프로그래머스] Lv.2 피로도 [Python, 파이썬] (0) | 2023.09.16 |
[프로그래머스] Lv.2 땅따먹기 [Python, 파이썬] (0) | 2023.09.03 |
Comments