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 7755065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:28:25+00:00 2026-06-01T12:28:25+00:00

Possible Duplicate: How to generate all permutations of a list in Python I want

  • 0

Possible Duplicate:
How to generate all permutations of a list in Python

I want to find all the permutations of a the elements in a list.
but then with some conditions imposed.. umm..
Probably an example will help me explain better.

I have four lists

["1"],["0"],["a","b","c],["d","e","f"]

Now I want to have the permutations in following way:

 "10ad" ,"10bd","10cd","10ae", "10be"
 ,"10bf"..

and so on..

So basically every element (with every element)??
Now I know the very naive way to do this.
But what is the pythonic way to do this?
if there is any??
Any suggestions

Thanks

  • 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-06-01T12:28:27+00:00Added an answer on June 1, 2026 at 12:28 pm

    I think you want to use the itertools module, which is part of the standard Python distribution.

    For example:

    import itertools
    
    a = ["1"]
    b = ["0"]
    c = ["a","b","c"]
    d = ["d","e","f"]
    
    for item in itertools.product(a, b, c, d): 
        print(item)
    

    Edit: To be clear, the itertools.product function provides all combinations for all items in the inputted lists, not permutations. But based on OP’s wording, I think this is what he/she actually wants.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Generate list of all possible permutations of a string I need to
Possible Duplicate: How to generate all permutations of a string in PHP? I want
Possible Duplicate: How do you efficiently generate a list of K non-repeating integers between
Possible Duplicate: Haskell ranges and floats If I generate a list in ghci like
This is related to question How to generate all permutations of a list in
Possible Duplicate: How do you generate dynamic (parameterized) unit tests in Python? Is there
Possible Duplicate: Generate MD5 hash in Java Hi, I want to compute the MD5
Possible Duplicate: Generate all combinations of arbitrary alphabet up to arbitrary length I'm trying
Possible Duplicate: How to find all possible subsets of a given array? How can
Possible Duplicate: Generate Random numbers uniformly over entire range I want to generate the

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.