# Getting an element of a sequence or a list: [] [[]] at

### 5.39.6 Getting an element of a sequence or a list: [] [[]] at

The elements of a sequence have indices beginning at 0 in Xcas mode and 1 in other modes (see Section 2.5.2).

You can get the an element of index n of a sequence or list by following the sequence or list with [n] (see Section 4.3.4).
(Note that head(S) does the same thing as S[0].)

#### Examples.

- Input:
  (0,3,2)[1]
  Output:

  3

- Input:

  S := 2,3,4,5
  S[2]

  Output:

  4

- Input:
  [A,B,C,D][2]
  Output:

  C

For lists, the at command can also be used to get the element at a specific position.

- at takes two arguments:
  - L, a list.
  - n, an integer.
- at(L,n) returns the element of S with index n.

Note. at cannot be used for sequences, since the second argument would be merged with the sequence.

#### Example.

Input:

[0,1,2][1]

or:

at([0,1,2],1)

Output:

1