인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

seoheeshin2809's profile image
seoheeshin2809

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

2. Kth number

슬라이싱 문의

Written on

·

175

0

a리스트의 s번째부터 e번째 까지의 슬라이싱 표현이 

강의에서는 a[s-1:e]

라고 하셨는데 

 

이해가 잘안되어서 혹시 자세한 설명과 함께 

a[s-1,e-1] 이 될수는 없는지요

python코테 준비 같이 해요!

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

a 배열의 0번 인덱스에 1번째가 들어가 있습니다. 그러니 s번째는 s-1인덱스에 있겠지요. 마찬가지로 e번째 값은 e-1번 인덱스에 있습니다. 그런데 리스트 슬라이싱은 a[2:5]로 하면 a리스트 2번 인덱스부터 4번인덱스까지 슬라이싱합니다.

seoheeshin2809's profile image
seoheeshin2809

asked

Ask a question