I need to do some special operation for the last element in a list. Is there any better way than this?
array = [1,2,3,4,5]
for i, val in enumerate(array):
if (i+1) == len(array):
// Process for the last element
else:
// Process for the other element