[프로그래머스] 숫자 문자열과 영단어

yewon Lee·2023년 4월 12일
1

😎코딩테스트 연습>2021 카카오 채용연계형 인턴십>숫자 문자열과 영단어


📘 문제 풀이

문자열을 바꾸는 방법 string.replace("변경 전 문자", "변경 후 문자")

def solution(s):
    num = ['zero','one','two','three','four','five', 'six', 'seven', 'eight', 'nine']
    for n in range(10):
        s = s.replace(num[n], str(n))
    return int(s)
profile
시작

0개의 댓글

Powered by GraphCDN, the GraphQL CDN