The simplest way is to use itertools.product
:
a = ["foo", "melon"]
b = [True, False]
c = list(itertools.product(a, b))
>> [("foo", True), ("foo", False), ("melon", True), ("melon", False)]
More Related Contents:
- How can I match up permutations of a long list with a shorter list (according to the length of the shorter list)? [duplicate]
- Removing duplicates in lists
- How to generate all permutations of a list?
- How to efficiently compare two unordered lists (not sets) in Python?
- Pythonic way to check if a list is sorted or not
- Detecting consecutive integers in a list [duplicate]
- How to efficiently compare two unordered lists (not sets)?
- Generate all permutations of a list without adjacent equal elements
- In Python, what is the fastest algorithm for removing duplicates from a list so that all elements are unique *while preserving order*? [duplicate]
- Checking if all elements in a list are unique
- How do I generate all permutations of a list?
- N-D version of itertools.combinations in numpy
- Complexity of list.index(x) in Python
- Python: find closest string (from a list) to another string
- all permutations of a binary sequence x bits long
- Replace list of list with “condensed” list of list while maintaining order
- Sliding window maximum in O(n) time
- How to split an iterable into two lists with alternating elements
- Python – Removing overlapping lists
- Getting the subsets of a set in Python
- Find non-common elements in lists
- Find intersection of two nested lists?
- Understanding recursion in Python
- Simple Python Challenge: Fastest Bitwise XOR on Data Buffers
- Head and tail in one line
- What’s the algorithm of ‘set.intersection()’ in python?
- Is there a way to circumvent Python list.append() becoming progressively slower in a loop as the list grows?
- How can I interleave or create unique permutations of two strings (without recursion)
- Python and SQLite: insert into table
- How can I turn a flat list into a 2D array in python?