I have a piece of code, which is a function called within a loop over a dictionary, it is as follows:
hope = []
seconds = []
hope.append(self.date)
for those in hope:
date = those
pattern = '%m/%d/%Y'
epoch = int(time.mktime(time.strptime(date, pattern)))
seconds.append(epoch)
print seconds
I am getting results like
[1505084400]
[1500850800]
[1509926400]
[1496617200]
[1492383600]
[1488758400]
[1499036400]
[1511136000]
[1511136000]
…
But I want the results of seconds to be like:
[1505084400,1500850800,1509926400,1496617200,1492383600,1488758400,1499036400,1511136000,1511136000.....]
So that the sort and sorted functions will work on it.
Just take the print statement out of the for loop and maintain the state of the lists: