0

I have a variable X, it contains a list (Python list), of 10 Numpy 1-D arrays (basically vectors). If I ask for X[100], it throws an error saying: IndexError: list index out of range

Which makes total sense, but, when I ask for X[:100], it doesn't throw an error and it returns the entire list! Why is that?

Alex
  • 599
  • 1
  • 5
  • 14

1 Answers1

1

X[:100] means slice X from 0 to 100 or the end (whichever comes first) But X[100] means the 100th element of X, and if it doesn't exist it throws an index out of range error

Amir
  • 1,885
  • 3
  • 19
  • 36