If statement based on item index

I have an arbitrary list of data that will vary in length. I have two basic expressions to apply to the data in these lists. Items with index 0 and -1 (start, end) need to be operated on by expression1, all other indexes will follow expression2.

Does anyone have ideas for a tidy, compact method to achieve this? My first though is expression editor but I am not certain if this can process if/else logic to check the index of the input data.

Any idea gratefully received.

Python? You could pop() the first and last items in the list and create a new two item list for those, then operate expression one on those and expression two on the original list (now truncated).

Or, if the main list needs to stay intact, then just an if statement as you iterate the list with enumerate

my_list=["A","B","C","D","E"]
for i, item in enumerate(my_list):
    print("Item at index {} = {}".format(i,my_list[i]))
    if i==0 or i==len(my_list)-1:
        print("Execute expression 1 on index {}".format(i))
    else:
        print("Execute expression 2 on index {}".format(i))