Is there a way to slice only the first and last item in a list?
For example; If this is my list:
>>> some_list [\'1\', \'B\', \'3\', \'D\',
You can use something like
y[::max(1, len(y)-1)]
if you really want to use slicing. The advantage of this is that it cannot give index errors and works with length 1 or 0 lists as well.