python - Turning a list of lists into a dictionary of lists -


hi there having small problem code trying implement. wish convert list of lists dictionary keys refer lists position in original list of lists, , values list of items in said list (from original list of lists). wish remove of nones present in original list of lists. example:

[[(1, none), (2, none)], [(0, none), (2, none)], [(1, none), (0, none)]] 

i want become:

{0: [1, 2], 1: [0, 2], 2: [1, 0]} 

looks basic dict , list comprehension

raw = [[(1, none), (2, none)], [(0, none), (2, none)], [(1, none), (0, none)]] print {i: [el[0] el in l] i, l in enumerate(raw)} 

prints

{0: [1, 2], 1: [0, 2], 2: [1, 0]} 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -