In reference to my previous question (Solved): Only show certain number of emails in imaplib
So now I can show certain number of emails in my inbox but the problem I'm having now is that I would like to output it in descending order.
It says here: http://pythoncentral.io/how-to-slice-listsarrays-and-tuples-in-python/
>>> a[::-1]
[8, 7, 6, 5, 4, 3, 2, 1]
"And that -1 I snuck in at the end? It means to increment the index every time by -1, meaning it will traverse the list by going backwards."
So im thinking backwards is equal to descending right? I tried to add the -1 on the code that I have already working:
ids = data[0]
id_list = ids.split()
for num in id_list[0:10:-1]:
rv, data = M.fetch(num, '(RFC822)')
msg = email.message_from_string(data[0][1])
subj = msg['Subject']
to = msg['To']
frm = msg['From']
body = msg.get_payload()
print subj
But there was no output.. I was expecing
tenth
ninth
eigth
.
.
.
.
second
first
But I didn't get any.. Any help on how I can achieve the output I want?