I have a list of floats that somewhat looks like this:
[
163.33333333333334,
0.0,
0.0,
154.73684210526315,
172.94117647058823,
155.8303886925795,
0.0,
156.93950177935943,
0.0,
0.0,
0.0,
151.5463917525773,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
165.1685393258427,
156.93950177935943,
169.6153846153846,
159.7826086956522,
167.04545454545453,
158.06451612903226,
168.9655172413793,
157.5,
0.0,
159.7826086956522,
0.0,
163.94052044609666,
166.41509433962264,
0.0,
0.0,
0.0,
]
The actual list is much larger than this but has similar values.
From this list, I want to find the largest consecutive subset of this that is nonzero. In this case that would be:
[165.1685393258427,
156.93950177935943,
169.6153846153846,
159.7826086956522,
167.04545454545453,
158.06451612903226,
168.9655172413793]
I am new to python and python and coding in general so any help would be greatly appreciated.
question from:
https://stackoverflow.com/questions/65893675/how-to-find-the-longest-consecutive-non-zero-subset-of-a-list