I know how to get the last item in a list myList:
myList[-1]
But how would I get the second last, or the nth last item in a string, without doing something like this:
myList[len(myList)-(n-1)
Second last would be myList[-2], nth last is myList[-n] You can read about negative indexing here
myList[-2]…!? If2is a variable,-n…?