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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:10:50+00:00 2026-06-02T09:10:50+00:00

how do i combine n items from iterable1 with m items from iterable2? i.e.

  • 0

how do i combine n items from iterable1 with m items from iterable2?

i.e.

iterable1 = [0,1,2,3,4]
iterable2 = ['a','b','c']
BlackBox(itertools.combination(iterable1, 2),itertools.combination(iterable2, 1)) yields
(0,1,'a'), (0,1,'b'), (0,1,'c'), (0,2,'a'), (0,3,'a'), etc. Order doesn't matter

I’m receiving a list of elements, which may contain a wildcard which I then need to replace with all of the wildcard’s possible values. I check for the number of wildcards and need to add a combination of that many elements into my de-wildcarded list. In other words, iterable2 is all the possible values of the wildcard, m is the number of wildcards, iterable1 is the original list with all wildcards removed, and n is the number of desired items less m.

  • 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-02T09:10:52+00:00Added an answer on June 2, 2026 at 9:10 am
    >>> iterable1 = [0,1,2,3,4]
    >>> iterable2 = ['a','b','c']
    >>> import itertools as it
    >>> list(x+y for x,y in it.product(it.combinations(iterable1, 2), it.combinations(iterable2, 1)))
    [(0, 1, 'a'), (0, 1, 'b'), (0, 1, 'c'), (0, 2, 'a'), (0, 2, 'b'), (0, 2, 'c'), (0, 3, 'a'), (0, 3, 'b'), (0, 3, 'c'), (0, 4, 'a'), (0, 4, 'b'), (0, 4, 'c'), (1, 2, 'a'), (1, 2, 'b'), (1, 2, 'c'), (1, 3, 'a'), (1, 3, 'b'), (1, 3, 'c'), (1, 4, 'a'), (1, 4, 'b'), (1, 4, 'c'), (2, 3, 'a'), (2, 3, 'b'), (2, 3, 'c'), (2, 4, 'a'), (2, 4, 'b'), (2, 4, 'c'), (3, 4, 'a'), (3, 4, 'b'), (3, 4, 'c')]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a requirement to load a list of items(ArrayList) from two different tables.
I want to combine multiple lists of items into a single list, retaining the
HI, I am working on a simple class to combine items of any type...
I would like to display items from a Queue in a Gridview in Windows
I'm trying to combine a static hard coded string with one referenced from strings.xml
I'm trying to combine the codes from these two questions: using jQuery to slideToggle
I'm using Sencha's Ext.data.Store to hold some items. Right now they come from an
im trying to grab search items from twitter via PHP curl, process and update
I'm trying to combine a number of List<T> where T:IGetTime (i.e T will always
I wan't to combine two lists of string, both of them have 200000+ items

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.