Something like the following should work, if you don't want to use itertools
like the linked answer did:
First, maintain a list of indices, let's call it positions
, that represent what elements you're currently looking at in each of the inner lists, and initialise all of these indices to 0. In your example given this would look like [0,0,0]
Print out / store the combination that results from these indices. Here that would be 1, 4, 7.
Increment the last index in the list. If this index is now the size of the list it corresponds to (in the example, for the last index, that would be 3, for the second last, 2, etc.) then reset it to 0 and increment the next index along instead. Do this check for all the values in positions
Repeat this process, printing out / storing the resulting combination each time, until the very first index in positions
reaches the size of the first list in your list of lists, at which point you're done