My subjective opinion is that 'not finding good logic' starts with bad naming habits. What are H and I? The last name ('I') I would call 'crime against readers of your code', PEP8 Names to avoid:
I add that 'l' and 'I' are also pretty similar to each other.
Now to problem at hand: list comprehension could be suitable tool:
Quote:Never use the characters 'l' (lowercase letter el), 'O' (uppercase letter oh), or 'I' (uppercase letter eye) as single character variable names.
In some fonts, these characters are indistinguishable from the numerals one and zero. When tempted to use 'l', use 'L' instead.
I add that 'l' and 'I' are also pretty similar to each other.
Now to problem at hand: list comprehension could be suitable tool:
>>> target = [[1,2],[3,4]] >>> source = [5,6] >>> [[*item, num] for num in source for item in target] [[1, 2, 5], [3, 4, 5], [1, 2, 6], [3, 4, 6]]
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.
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.