Subscripting and slicing and reverse order in strings of Python learning

Subscripts in python start at 0

Take from back to front

Note: The following 2 represents the step size, first look at the value taken out by 2:-1

[Start Position:End Position:Step]

reverse order

But it is found that if [-1:0:-1] finds that the first element cannot be obtained, what should I do?

At this time, just remove the 0 in the middle, and removing it means getting the first element. If it is empty, then by default, the first or last element will be found.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324940849&siteId=291194637