Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 256 Bytes

슬라이싱을 문자열 끝을 기준으로 하는 법.md

File metadata and controls

12 lines (9 loc) · 256 Bytes

슬라이싱을 문자열 끝을 기준으로 하는 법

s = 'Hello, world!'

print(s[-3:])   # 뒤에서 3번째 문자부터 ~ 끝까지
print(s[-5:-1]) # 뒤에서 5번째 문자부터 ~ 뒤에서 2번째 문자까지

# 출력
ld!
orld