Re: [Tutor] Guidance if possible

2013-04-12 Thread Wayne Werner
On Fri, 12 Apr 2013, Alan Gauld wrote: On 11/04/13 23:33, Scurvy Scott wrote: the other for something like this. I have no intention of doing anything professional/shady/annoying with this code and want to write it purely for my own amusement as well as to learn and obviously to perhaps win so

[Tutor] creating dictionary from a list

2013-04-12 Thread Saad Bin Javed
Hi, I'm using a script to fetch my calendar events. I split the output at newline which produced a list 'lst'. I'm trying to clean it up and create a dictionary with date:event key value pairs. However this is throwing up a bunch of errors. lst = ['', 'Thu Apr 04 Weigh In', '', 'Sat

Re: [Tutor] creating dictionary from a list

2013-04-12 Thread Steven D'Aprano
On 13/04/13 09:52, Saad Bin Javed wrote: Hi, I'm using a script to fetch my calendar events. I split the output at newline which produced a list 'lst'. I'm trying to clean it up and create a dictionary with date:event key value pairs. However this is throwing up a bunch of errors. Would you

Re: [Tutor] creating dictionary from a list

2013-04-12 Thread Saad Bin Javed
Thank you Steven! I followed your tips and came up with this: lst = filter(None, lst) lst = [item.split(' ', 1) for item in lst] lst = [item for sublist in lst for item in sublist] lst = filter(None, lst) dict = {} for item in lst: if item.startswith(('Mon','Tue','Wed','Thu','Fri','Sat'