How to treat the last element in list differently in Python?
<p>I need to do some special operation for the last element in a list.
Is there any better way than this?</p>

<pre>
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 
</pre>
