"comprehend" into a single value

Andrew Z formisc at gmail.com
Sat Oct 7 23:07:45 EDT 2017


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



More information about the Python-list mailing list