دنبال کننده ها

۱۳۹۶ مرداد ۱۲, پنجشنبه

Making multiple output lists into one list [python]

[ad_1]



I have this generator



def keys():
objects = ['1':True,'2':True,'3':False,'4':False,'5':True,'6':True]
rng = range(len(objects))
clean = int(''.join(map(str, rng)))
for keys, values in objects[clean].iteritems():
if values == True:
yield keys


and then i want to get all the generator values, which I do using for loop



for i in keys():
i= i.split()
print i


and the output is :



['1']
['2']
['5']
['6']


is there a way I can add them to a single list?
like [['1'],['2'],['5'],['6']] or most preferably ['1','2','5','6'].
Would greatly appreciate your help. Thanks




[ad_2]

لینک منبع