Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7566775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:29:58+00:00 2026-05-30T14:29:58+00:00

I have lists like: L1 = [list] L2 = [ [l1], [l2], …, [ln]

  • 0

I have lists like:

L1 = [list]

L2 = [ [l1], [l2], ..., [ln] ]

I need to map these lists to

L = [ [list+l1] , [list + l2] , ..., [list + ln] ]

Right now I am just repeating L1 n times and then zipping them. Can someone please hint me to a more elegant way? In other words, I am looking to do this:

L=[]
L.append(L1 + L2[0])
L.append(L1 + L2[1])
...

It would also be nice if the solution would be robust to the following change:

L1 = [list1, list2, ..., listk]

and then L becomes

[ [list1 + list2 + ... + listk + l1] , ..., [list1 + list2 + ... + listk + ln] ]

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:30:00+00:00Added an answer on May 30, 2026 at 2:30 pm
    L=[]
    L.append(L1 + L2[0])
    L.append(L1 + L2[1])
    ...
    

    is equivalent to

    L = [ L1+item for item in L2 ]
    

    If L1 = [list1, list2, ..., listk] is a list of lists, such as

    In [43]: L1 = [[1,2],[2,3]]
    

    then list1 + list2 + ... + listk can be formed with sum(L1, []):

    In [44]: sum(L1,[])
    Out[44]: [1, 2, 2, 3]
    
    In [45]: [1,2]+[2,3]
    Out[45]: [1, 2, 2, 3]
    

    So in this case you could use

    L1_sum = sum(L1, [])
    L = [ L1_sum+item for item in L2 ]
    

    (Aside: It is also possible to use L = [ sum(L1, [])+item for item in L2 ] but this would repeat the calculation of sum(L1, []) once for each item in L2.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a list of lists that looks like this: dupe = [['95d1543adea47e88923c3d4ad56e9f65c2b40c76', 'ron\\c',
I have a list of lists that looks like this: x[[state]][[year]] . Each element
I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
As per the title, I have a nested lists like so (the nested list
I have a very deep list of lists in R. Now I want to
i have List of int which consists of value 0,0,0,1,2,3,4,0,0 now i like to
I have a couple of lists like this: <ul> <li class=list-header>Header</li> <li>Item 1</li> <li>Item
I have two lists List<WorkOrder> and List<PlannedWork> I would like join the two lists
I have several lists of strings like so, from a possible list of several
I have two lists xscat and yscat. I would like the list comprehension to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.