일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Jest
- 타입 좁히기
- map
- tailwind
- webpack
- SSR
- recoil
- 리터럴 타입
- React
- 무한 스크롤
- app router
- TS
- Cypress
- CORS
- 태그된 유니온
- ESlint
- CI/CD
- 이분 검색
- RTK Query
- dfs
- 공변성
- 결정 알고리즘
- 인터섹션
- 반공변성
- autosize
- Promise
- useAppDispatch
- 호이스팅
- 투포인터
- async/await
Archives
- Today
- Total
짧은코딩
프로그래머스) 숫자 문자열과 영단어 본문
반응형
https://programmers.co.kr/learn/courses/30/lessons/81301
내 풀이(맞음, 근데 이렇게 풀어도되나...?)
def solution(s):
answer = 0
s = s.replace('zero', '0')
s = s.replace('one', '1')
s = s.replace('two', '2')
s = s.replace('three', '3')
s = s.replace('four', '4')
s = s.replace('five', '5')
s = s.replace('six', '6')
s = s.replace('seven', '7')
s = s.replace('eight', '8')
s = s.replace('nine', '9')
answer = int(s)
return answer
문자열은 int형으로 replace 해주지 못한다. 그래서 1을 '1'로 써야하는 것을 주의해야한다.
반응형
'코딩 테스트(Python) > 백준, 프로그래머스' 카테고리의 다른 글
7662 이중 우선순위 큐 (0) | 2022.04.08 |
---|---|
프로그래머스) 완주하지 못한 선수 (0) | 2022.04.06 |
프로그래머스) 오픈채팅방 (0) | 2022.03.29 |
프로그래머스) 크레인 인형뽑기 게임 (0) | 2022.03.27 |
프로그래머스) 신규 아이디 추천 (0) | 2022.03.25 |
Comments