Necesito hacer alguna operación especial para el último elemento en una lista. ¿Hay alguna manera mejor que esto?¿Cómo tratar el último elemento de la lista de manera diferente en Python?
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
Posible du plicate of [Identifique en qué iteración se encuentra en un bucle en python] (http://stackoverflow.com/questions/4751092/identify-which-iteration-you-are-on-in-a-loop-in-python) –