Find a subtext between two positions in a larger text, after assigning variables to the first and last points

In continuation to this question (link), I am trying to find the subtext between two points in a larger text (target).

When I write:

target[2735:2738]

I get the correct answer “1.32”

However, when I instead assign the start id (2735) to a variable, and do the same for the last id (2738) and write:

target[firstid:lastid)

I get an error (see the image for complete details):

What is the correct procedure?

Try target[firstid:lastid] instead of target[firstid:lastid), as the error message suggests.

2 Likes

Oh, that’s embarrassing.