continue # skip such lines
>
> fields = line.split()
>
> date = datetime.strptime(fields[0], DATE_FORMAT).date()
> white_balls = frozenset(int(num_str) for num_str in fields[1:6])
> powerball = int(fields[6])
> ticket = Ticket(white_balls, powerball, date)
>
> powerball2ticket[powerball].add(ticket)
> for ball in white_balls:
> whiteball2ticket[ball].add(ticket)
> tickets_by_date.append(ticket)
>
> tickets_by_date.sort(key=lambda ticket: ticket.date)
>
> print(powerball2ticket[7]) # all tickets with a 7 powerball
> print(whiteball2ticket[3]) # all tickets with a non-power 3 ball
>
>
> Cheers,
> Chris
> --
> http://rebertia.com
>
--
Troy S
--
http://mail.python.org/mailman/listinfo/python-list
0827', '20110831', '20110903', '20110907', '20110910']
The keys are strings that represent a date in the format: 'MMDD'.
Thanks,
On Fri, Oct 14, 2011 at 6:24 PM, Ian Kelly wrote:
> On Fri, Oct 14, 2011 at 4:10 PM, MrPink wrote:
>> I have a list like so:
>>
>> a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14]
>>
>> I would like to get a subset from the list with value between 10 and
>> 20 (inclusive).
>>
>> b = [10,13,15,14,20]
>>
>> Is there a way to do this with a list or other data type?
>
> Use a list comprehension:
>
> b = [x for x in a if 10 <= x <= 20]
>
> Cheers,
> Ian
>
--
Troy S
--
http://mail.python.org/mailman/listinfo/python-list