One basic question in list comprehension as i am starting on that,
can a list comprehension return two arrays?
like I was trying to convert my code to list comprehension
b=[10,2,3]
c=[10,11,12]
d=[]
f=[]
a=10
for i in b:
if a>i:
for j in c:
d.append(j)
print d
I am able to convert the above code using list comprehension as
print [j for i in b if a>i for j in c ]
But now I want to add an extra else block to my initial code and looks like
b=[10,2,3]
c=[10,11,12]
d=[]
f=[]
a=10
for i in b:
if a>i:
for j in c:
d.append(j)
else:
f.append(i)
print d
print f
d=[10, 11, 12, 10, 11, 12]
f=[10]
is there any way I can add this extra else to my initial list comprehension?