Reputation: 49
I am running a series of data (day wise) through the script in for loop. After each iteration the results are displayed and then the next day in series is considered for the same program. I would like to display all the results together at the end than seperately after each dataset run. Can anyone help me?
My for loop starts as below:
start_evt_list= ['2016_01_03_15_0_0','2016_01_07_08_00_00','2016_01_10_12_0_0', ...]
N_evt = [256, 256, 256,...]
for i in range(n):
start_evt=datetime.strptime(start_evt_list[i], '%Y_%m_%d_%H_%M_%S')
After a series of operations, I get output for the day in muliple values like this:
print('D1 = ',D1)
print('D2 = ',D2)
print('D3 = ',D3)
Then the code takes the next day and repeats the process.
I am looking for a way to display D1,D2,D3 for every day at the end of program as single final result than seperate displays in between.
Upvotes: 1
Views: 68
Reputation: 1823
Initialize a list outside the loop
result = []
Instead of print('D1 = ', D1)
do result.append((D1,D2,D3))
Finally, you can display them like this:
for val in result:
print('D1 = ',val[0])
print('D2 = ',val[1])
print('D3 = ',val[2])
Upvotes: 2