title: Is there a way to create combinations that preserve the order of elements in a list?
body: <p>I have a function that supplies me with a list of lists. The length of the list corresponds to the length of the combination, while the length of the sublist corresponds to the different letters that can be used in that position. So, for instance the expected combinations for this list <code>[['W'], ['I'], ['C', 'J'], ['K', 'Y']]</code> are &quot;WICK&quot;, &quot;WICY&quot;, &quot;WIJK&quot;, and &quot;WIJY&quot;. I know how to generate those combinations using nested for loops as follows:</p>
  <pre><code>for a in lst[0]:
      for b in lst[1]:
          for c in lst[2]:
              for d in lst[3]:
                  print(a+b+c+d) 
  </code></pre>
  <p>However, since the length of each list may vary, doing it manually is not feasible for my program. Is there a way I can do this automatically?</p>