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'

0

1 Answer 1

7

That would be using index [-1].

A[0][-1]

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.