728x90
Programmers
숫자 문자열과 영단어
https://school.programmers.co.kr/learn/courses/30/lessons/81301
문제
코드
def solution(s):
answer = 0
words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
for i in words:
if i in s:
idx = str(words.index(i))
s = s.replace(i, idx)
return int(s)
728x90
반응형
'Algorithm' 카테고리의 다른 글
[프로그래머스] 문자열 내 마음대로 정렬하기 - 파이썬 (0) | 2024.04.25 |
---|---|
[프로그래머스] 가장 가까운 같은 글자 - 파이썬 (0) | 2024.04.25 |
[프로그래머스] 최소직사각형 - 파이썬 (0) | 2024.04.24 |
[프로그래머스] 크기가 작은 부분문자열 - 파이썬 (0) | 2024.04.24 |
[프로그래머스] 삼총사 - 파이썬 (0) | 2024.04.24 |