I have a list of including some cost values for a project. The list c
says that a project started in year 1 (assuming c[0] = year 1
, suspended in year 3, and completed at the end of year 4. So, there is no associated cost in year 5.
c = [3000000.0, 3000000.0, 0.0, 200000.0, 0.0]
From the list, I want to find the project length, which is basically 4
not 3
in the above example based on my way of programming. If the list would be as following:
d = [3000000.0, 3000000.0, 100000.0, 200000.0, 0.0]
I could have the following to solve my problem:
Input:
cc = 0
for i in d:
if i>0:
cc += 1
Output:
cc = 4
However, it does not really work when there is a suspension(gap) between two years. Any suggestions to make it work?