there are 31 days in the month so i'm trying to take the last 5 days in this case
That would be something along the lines of:
print range(32)[-5:]
woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
Is this helpfull?
import random
test_data = [random.randint(28,31) for count in range(12)]
day_data = [[random.randint(1,5)
for count in range(days)]
for days in test_data ]
print('Data generated')
for m, month in enumerate(day_data):
print(m+1, month)
n = 5
for m, month in enumerate(day_data):
print('Last %i days measurements for month %i are:\n%s' % (n, m+1, month[-n:]))
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852