##### Add items from one list to list of lists
 Add items from one list to list of lists PUP280 Programmer named Tim Posts: 10 Threads: 3 Joined: Mar 2020 Reputation: Mar-24-2020, 10:50 AM (This post was last modified: Mar-24-2020, 11:07 AM by buran.) Hello, I would like to add every element of a list on every list from a list of lists. Ie : ```H = [[1,2],[3,4]] I = [5,6]```With this result : ``Output:J = [[1,2,5], [3,4,5], [1,2,6], [3,4,6]]``I don’t find the good logic. Ie : ```j = [] for x in h : for y in i : j.append(h+i) print (j)```Gives me : ``````Output:[[[1, 2], [3, 4], 5, 6]] [[[1, 2], [3, 4], 5, 6], [[1, 2], [3, 4], 5, 6]] [[[1, 2], [3, 4], 5, 6], [[1, 2], [3, 4], 5, 6], [[1, 2], [3, 4], 5, 6]] [[[1, 2], [3, 4], 5, 6], [[1, 2], [3, 4], 5, 6], [[1, 2], [3, 4], 5, 6], [[1, 2], [3, 4], 5, 6]]``````Or again : ```k = [] for w in h : for z in i : o = [w,z] k.append(o) print (k)```Will give : ``````Output:[[[1, 2], 5]] [[[1, 2], 5], [[1, 2], 6]] [[[1, 2], 5], [[1, 2], 6], [[3, 4], 5]] [[[1, 2], 5], [[1, 2], 6], [[3, 4], 5], [[3, 4], 6]]``````I’ve tried some tests with map, but nothing conclusive. Can you help me please to solve my problem ? Reply

 Messages In This Thread Add items from one list to list of lists - by PUP280 - Mar-24-2020, 10:50 AM RE: Add items from one list to list of lists - by perfringo - Mar-24-2020, 12:36 PM RE: Add items from one list to list of lists - by PUP280 - Mar-28-2020, 08:34 AM RE: Add items from one list to list of lists - by perfringo - May-02-2020, 12:37 PM RE: Add items from one list to list of lists - by pyzyx3qwerty - May-02-2020, 01:50 PM RE: Add items from one list to list of lists - by PUP280 - May-05-2020, 03:47 PM

 Possibly Related Threads… Thread Author Replies Views Last Post behavior list of lists roym 5 242 Jul-04-2021, 04:43 PM Last Post: roym Compile list of dictianories out of another list of dictianories by certain keys CatorCanulis 10 644 Jun-10-2021, 08:35 PM Last Post: perfringo Feed List items with Integer euras 9 589 May-19-2021, 07:45 PM Last Post: snippsat List of lists - merge sublists with common elements medatib531 1 523 May-09-2021, 07:49 AM Last Post: Gribouillis Sort List of Lists by Column Nju 1 475 Apr-13-2021, 11:59 PM Last Post: bowlofred Parse String between 2 Delimiters and add as single list items lastyle 5 616 Apr-11-2021, 11:03 PM Last Post: lastyle Order a list with successive permutations based on another list yvrob 3 614 Mar-19-2021, 08:20 AM Last Post: supuflounder Saving list in a list quest_ 3 740 Mar-10-2021, 09:58 AM Last Post: quest_ Convert Bytearray into List using list() Shlok 2 508 Feb-18-2021, 10:44 AM Last Post: deanhystad Sum of list items tristanfermat 2 526 Feb-06-2021, 12:04 PM Last Post: tristanfermat

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020