Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 981187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:30:09+00:00 2026-05-16T04:30:09+00:00

I am in desperate need for some algorithm help when combining lists inside lists.

  • 0

I am in desperate need for some algorithm help when combining lists inside lists. Assuming that I have the following data structure:

fields = [  ['a1', 'a2', 'a3'],
            ['b1', 'b2', 'b3'],
            ['c1', 'c2', 'c3'],
            ['d1', 'd2', 'd3']  ]

I am trying to write a generator (Python) that will yield each possible combination of the items so that the following code:

for x in thegenerator(fields):
    print(x)

would give the following output:

['a1', 'b1', 'c1', 'd1']
['a1', 'b1', 'c1', 'd2']
['a1', 'b1', 'c1', 'd3']
['a1', 'b1', 'c2', 'd1']
['a1', 'b1', 'c2', 'd2']
['a1', 'b1', 'c2', 'd3']
...
['a3', 'b3', 'c3', 'd3']

However, my mindset is completely off today so I can not think how I best can iterate the structure to get all the combinations the most clean way using Python. I am sure this has been done before by someone, but after a few searches on google and stack I have given up finding the correct combination of keywords in order to find a suitable algorithm for this problem.

Any ideas what the most clean algorithm to fix this would be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:30:09+00:00Added an answer on May 16, 2026 at 4:30 am
    itertools.product(*fields)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really need help here. I'm desperate at this point. I have NSOperation that
I have a bunch of ZIP files that are in desperate need of some
Hello i am in desperate need of help on this i have an image
I desperately need some help on this one. I've created a <script> that closely
I'm in need of some desperate help. I've been at this for 4 hours,
I am in desperate need of help, I need to manage an application dependency
I'm in desperate need of help. I've been working on this for over 20
So I'm new in python and I desperately need help. I have a file
I currently have a web site hitting 7 Access DBs that I desperately need
First of all I am in DESPERATE need of help here PLEASE I will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.