0

today I was learning about list slicing in python, and I have a question about the rules by which python "operates/slices" these lists. How is it possible that I don't get an error message when clearly the range is wrong?

li=[1,2,3,4,5,6]

li[1:12:1]
  [2,3,4,5,6]

1 Answers1

0

there isnt an index error it just stops at the end:

li=[1,2,3,4,5,6]

print(li[:10])
print(li[:7])
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
Ironkey
  • 2,568
  • 1
  • 8
  • 30