Be Data
[프로그래머스 ]숫자 문자열과 영단어 : replace() 본문
2021 카카오 채용연계형 인턴십 > 숫자 문자열과 영단어 문제
https://school.programmers.co.kr/learn/courses/30/lessons/81301
python의 "replace()"를 이용하면 정말 쉽다!
replace의 정말 간단한 예로는
a= "Hello, This is BS"
a.replace("Hello", "Hi")
이렇게 하면
"Hi, This is BS" 가 출력된다!
따라서,
def solution(s):
en_list = ["zero","one","two","three","four","five","six","seven","eight","nine"]
for i in range(10):
s=s.replace(en_list[i],str(i))
return int(s)
'IT > python' 카테고리의 다른 글
| 파이썬 Collections 모듈 (0) | 2022.10.29 |
|---|---|
| 코테 보기 직전 (0) | 2022.10.29 |
| [파이썬 모듈] 리스트의 모든 조합 구하는 방법 (0) | 2022.09.21 |
| <문자열 처리> 관련 함수들 - python (0) | 2022.09.20 |
Comments