I have a list that I want to make sublists from it based on the percentage change of the elements inside the list. For example:
list=[11.7, 8.5, 11.3, 11.2, 10.8, 1.05]
plist = [100.0 * e1 / e2 - 100 for e1, e2 in zip(list[1:], list)]
plist is:
[-27.350427350427353, 32.94117647058823, -0.8849557522123916,
-3.5714285714285694, -90.27777777777777]
Any consecutive element's percentage change > -5 will get grouped into a sublist like,
[11.7, [8.5, 11.3, 11.2, 10.8], 1.05]
Are there any other ways to get the desired output without using the long list comprehension method?
listas variable name!"Any consecutive element's percentage change > -5 will get grouped into a sublist like, "