I am wanting to refer to a number of items from the end of a list, but can't get the syntax right,
previousDays = 5
pDaysRange = (31-previousDays,32)
previousDays is the variable I can change,
there are 31 days in the month so i'm trying to take the last 5 days in this case,
trainingDays = trainingData.getMeasurements()
for day in trainingDays:
for i in range(pDaysRange,32):
if day[i].condition == "Fog":
prevDaysF += 0.5
if day[i].condition == "Snow":
prevDaysS += 0.5
if day[i].condition == "Rain":
prevDaysR += 0.5
if day[i].condition == "None":
prevDaysN += 0.5
print prevDaysF
I know range doesn't work with anything but an integer, but i'm just illustrating what i need to happen,
this code will repeat for each of the other 4 days,
i can't repeat the code either as the number i'm implementing prevDays with is different with each day
I think i need to define the range similar to
for day in trainingDays
, but i'm not sure how to do this