6

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
  • 9,791
  • 3
  • 24
  • 31

1 Answers1

7

That would be using index [-1].

A[0][-1]

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

Cory Kramer
  • 114,268
  • 16
  • 167
  • 218