how to extract numbers from each position of a python list of lists -


i have list :

n=[[0,3,4], [0,1,2,9,3], [0,3]] 

how use ths list list each list item being number each positon of list items in n new list looks like:

newlist=[[0,0,0], [3,1,3],  [4,2] ,[9], [3]] 

so first item in newlist sublist contains first number in n[0], first number in n[1], , first number in n[2]. next sublist in n same second positions.

could make use of izip_longest, filter out default values, eg:

from itertools import izip_longest  n=[[0,3,4], [0,1,2,9,3], [0,3]]    new_list = [[el el in items if el not none] items in izip_longest(*n)] # [[0, 0, 0], [3, 1, 3], [4, 2], [9], [3]] 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -