목록index (1)
IT 세계의 후아
[python]문자열 인덱싱
※ 콜론[:]을 활용한 문자열 인덱싱text = 'abcdef'text[0] = 'a'text[0:2] = 'ab'text[-2:0] = 'ef'text[:-3] = 'abc'text[::2] = 'ace' # 0번째 문자부터 끝까지 2개씩 건너뛰기# 프로그래머스 lv0 코드 처리하기def solution(code): mode = False # 0 ret = "" for i in range(len(code)): if code[i] == "1": # 숫자 1이 아닌 문자열 1이라는 것 놓치지 않기! mode = not mode elif (mode == False and i%2 == 0) or (mode == True and i%2 == ..
Coding/Python
2024. 4. 17. 20:59