Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9448
| From | Emile van Sebille <emile@fenx.com> |
|---|---|
| Subject | Re: I don't know list, I not good at list. |
| Date | 2011-07-13 14:51 -0700 |
| References | <77AE044B1BF3944FAE2435F395F11B4B018599C6@clt-exmb02.bbtnet.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1008.1310593833.1164.python-list@python.org> (permalink) |
On 7/13/2011 2:13 PM Ellerbee, Edward said...
> I've been beating my head against the desk trying to figure out a method
> to accomplish this:
>
<snip>
> #-----------------------------------------------------------------
> My intent is to have the end data come out (from the example list above)
> in the format of
> 25220[56]
> 25224[678]
this should get you started...
>>> list1=['252205','252246','252206','252247','252248']
>>> D = {}
>>> for ii in list1: D.setdefault(ii[:5],[]).append(ii[5])
...
>>> print D
{'25224': ['6', '7', '8'], '25220': ['5', '6']}
>>>
Emile
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: I don't know list, I not good at list. Emile van Sebille <emile@fenx.com> - 2011-07-13 14:51 -0700
csiph-web