In Python, is there a good way to interleave two lists of the same length?
Say I’m given [1,2,3] and [10,20,30]. I’d like to transform those into [1,10,2,20,3,30].
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Having posted the question, I’ve realised that I can simply do the following:
where
l1andl2are the two lists.If there are N lists to interleave, then