"comprehend" into a single value
Nathan Hilterbrand
nhilterbrand at gmail.com
Sat Oct 7 23:17:08 EDT 2017
dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
p = sum([dict[i][1] for i in dict])
Something like that?
On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z <formisc at gmail.com> wrote:
> Hello,
> i wonder how can i accomplish the following as a one liner:
>
> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
> p = 0
> for i in dict:
> p += dict[i][1]
>
>
> Thank you
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list