Accessing elements

### 5.3.4 Accessing elements

The elements of sequences and lists are indexed starting from 0 in Xcas syntax mode and from 1 in all other syntax modes (see Section 3.5.2). To access an element of a list or a sequence, follow the list with the index between square brackets.

Examples.

- Input:
  L:= [2,5,1,4]
  Output:

  ⎡ ⎣ | 2,5,1,4 | ⎤ ⎦

- Input:
  L[1]
  Output:

  5

- To access the last element of a list or sequence, you can put -1 between square brackets.
  Input:
  L[-1]
  Output:

  4

If you want the indices to start from 1 in Xcas syntax mode, you can enter the index between double brackets.

Example.
Input:

L[[1]]

Output:

2