over 2 subsequent elements in a list inside a for loop/list comp? i feel like using, for example, lst[index] > lst[index+1] and use for index in range(len(lst)-1), is not very pythonic, maybe there's a better approach
The simplest way I could find is doing zip(lst, lst[1:])
i'm constructing a list using a comprehension, and i want to exclude every element that is smaller than its previous one
You could do it this way
cool! thank you
Use reduce
List(Reduce(lambda x,y: x if (x>y) else y, lst))
Обсуждают сегодня