data structures - Zipping unequal lists in python in to a list which does not drop any element from longer list being zipped -


I have two lists

  a = [1,2,3] b = [9,10]   

I want to combine these two lists in a list c

  c =      

What do you want

  & gt; & Gt; & Gt; A = [1,2,3]> gt; & Gt; & Gt; B = [9, 10]> gt; & Gt; & Gt; I for itertools.izip_longest (a, b): print i ... (1, 9) (2, 10) (3, none)   

Edit 1 : If you do not really want to get rid of any s, then you can try:

  & gt; & Gt; & Gt; For pair in (in itertools.izip_longest (a, b)) (filter (none, pair)): print i (1, 9) (2, 10) (3,)   

In reply to Stevaha's comment: Filter (Lambda P: P None, Not Pair) for pair in itertools.izip_longest (A, B)

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -