> > Don't fight Python, unlike this chap[1] :) Basically if you're looping > around any data structure you rarely need to use indexing, so try this > approach. > > for item in lst: > if item.startswith(('Mon','Tue','**Wed','Thu','Fri','Sat','Sun'))**: > myDict[item] = [] > saveItem = item > else: > myDict[saveItem].append(item.**strip()) >
This creates a dictionary whose keys are out of order in terms of dates. {'Thu Apr 04': ['Weigh In'], 'Sat Apr 06': ['Collect NIC', 'Finish PTI Video'], 'Wed Apr 10': ['Serum uric acid test'], 'Sun Apr 14': ['Download Louis CK Oh My God', '4:00pm', 'UPS Guy'], 'Sat Apr 13': ['1:00pm', 'Get flag from dhariwal']} Sat Apr 13 is appearing after Sun Apr 14. How do you sort this?
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor