5

When I work in Matlab, I use the refer to the last element of a vector with 'end'. For example:

A(1, end)

where A is a 2x2 matrix.

Can you tell me what is the equaivalent command in python? For example, I have the following variable, as an element of a list of strings:

dataList[loc] = ['%Case study: test\n']

so the last element should be '\n'

TheBlackCat
  • 8,821
  • 3
  • 21
  • 29

1 Answers1

6

That would be using index [-1].

A[0][-1]

Negative indices start at [-1] and increment from the back of the sequence.

Cory Kramer
  • 107,498
  • 14
  • 145
  • 201