2
I have a list that symbolizes a timeline:
linha_tempo = [1107, 1107, 0, 1104, 1104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1106, 1106, 0, 0, 0, 0, 0, 1102, 1102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1105, 1105, 1101, 1101, 0, 0, 1103, 1103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
What I need from here is to store the distances at which each first occurrence of an element other than 0 is from the next element other than 0.
Ex: 1107 is at a distance of 3 from 1104, to 1106 is at 36... and so on, I have to do this for all elements.
Great @Miguel, thank you so much! Helped me a lot! I could understand perfectly the logic, because of the comments!
– Allan
You’re welcome @Allan. I’m glad you figured it out and solved it
– Miguel