How do I make a generator from two lists in python? -


give lists a, b

a = [5, 8, 9] b = [6, 1, 0] 

i want create generator gen such that:

for x in gen:   print x 

outputs

5, 8, 9, 6, 1, 0 

you use itertools.chain:

>>> itertools import chain >>> = [5, 8, 9] >>> b = [6, 1, 0] >>> it=chain(a,b) >>> x in it:     print x, ...      5 8 9 6 1 0 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -