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:
- Permutations between two lists of unequal length
- 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?
- 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
- 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
- Join a list of items with different types as string in Python
- How to overcome TypeError: unhashable type: ‘list’
- How did Python implement the built-in function pow()?
- Removing elements from a list containing specific characters [duplicate]
- How to compare a list of lists/sets in python?
- Subtracting two lists in Python
- Python: determine if all items of a list are the same item [duplicate]
- How to flatten a hetrogenous list of list into a single list in python? [duplicate]
- Python: Choose random line from file, then delete that line
- TypeError: list indices must be integers or slices, not list
- Python: powerset of a given set with generators [duplicate]