I have a two python list like this
l1 = [[1,2],[3,4],[6,7]]
l2 = [[1,2],[3,4],[6,7],8]
I was able to flatten the list l1 like below
flattend_list = [e for sub in l1 for e in sub]
But I' unable to do it for list 2. I am not able to figure out how to add if else condition before 2nd for loop inside a primary for loop in list comprehension. Any idea, Thanks in advance.