my_list[-1:-5:-1]
The syntax is list_name[start:end:step] Since step is -1, we count backwards. Since start is -1, we start at the end of the list. Then we count backwards to (but not including) index -5. So, assuming the list contains four or more items, we'll get values for indexes -1, -2, -3, and -4. That will reverse the order of the elements in the list. I hope that helps...
2017 Nov 28, 2:16:36 PM
Login in to like
Login in to comment