1

What is the length of d? d = [1, 2, 3][1:]. I can't understand what the [1:] mean at the end.

Manu Chadha
  • 13,750
  • 13
  • 62
  • 153

1 Answers1

1

It’s referred to as ‘slicing’. Examples shown here.

From element 1 (the second element) through to the end, therefore a length of 2.

Aside: You’d (hopefully) never see this exact case in real-world practice, as it’s nonsense.

S3DEV
  • 6,600
  • 3
  • 24
  • 36
  • it means we can assign number of Values in a lsit and in the same line by using slicing we can restrict to choose and store some specific value. @S3DEV – Ankit gupta Aug 08 '21 at 10:03