Python Forum
Insert into sublist if sublist is not having same no of records.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert into sublist if sublist is not having same no of records.
#6
It's probably not the answer you looking for, but "the way to fill zero's" in case of iterables is:

>>> from itertools import zip_longest
>>> a = [1, 2, 3]
>>> b = [10, 20, 30, 40]
>>> list(zip_longest(a, b, fillvalue=0))
[(1, 10), (2, 20), (3, 30), (0, 40)]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Insert into sublist if sublist is not having same no of records. - by perfringo - May-16-2019, 08:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Use one list as search key for another list with sublist of list jc4d 4 2,334 Jan-11-2022, 12:10 PM
Last Post: jc4d
Question Sublist/ Subarray into string Python SantiagoPB 2 2,238 Apr-23-2021, 07:03 PM
Last Post: SantiagoPB
  List of objects with sublist medatib531 4 2,472 Mar-01-2020, 06:16 PM
Last Post: buran
  Split List and Sublist from Pyodbc parthi1705 1 2,312 May-05-2019, 10:44 AM
Last Post: Larz60+
  merging sublist into single list in python abhishek8singhai 8 9,821 Mar-22-2019, 11:46 PM
Last Post: micseydel
  Can I use a sublist as an argument in python? MartinBerlin 3 4,181 Aug-25-2018, 10:46 AM
Last Post: buran
  Insert using psycopg giving syntax error near "INSERT INTO" olgethorpe 4 15,908 Jul-21-2017, 07:39 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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