How do I criss cross two lists together in python? Example:
list_1 = [1, 2, 3]
list_2 = [4, 5, 6]
Expected Outcome:
combined_list = [1, 4, 2, 5, 3, 6]
How do I criss cross two lists together in python? Example:
list_1 = [1, 2, 3]
list_2 = [4, 5, 6]
Expected Outcome:
combined_list = [1, 4, 2, 5, 3, 6]
A pythonic way of doing this:
[item for sublist in zip(a,b) for item in sublist]
Per the request, if you only want a list if the two lists are the same length, you can use:
[item for sublist in zip(a,b) for item in sublist if len(a) == len(b)]
And see if the result is an empty list.