Add function to generate all possible pairs from a list

This commit is contained in:
Hope Ogbons
2025-10-27 06:17:11 +01:00
parent 8faff0283b
commit a3d65bfe21

View File

@@ -0,0 +1,9 @@
# Python Function
# This function takes a list of items and returns all possible pairs of items
def all_pairs(items):
pairs = []
for i in range(len(items)):
for j in range(i + 1, len(items)):
pairs.append((items[i], items[j]))
return pairs