From a3d65bfe21ee894e77fe747949b5302468fcfdcc Mon Sep 17 00:00:00 2001 From: Hope Ogbons Date: Mon, 27 Oct 2025 06:17:11 +0100 Subject: [PATCH] Add function to generate all possible pairs from a list --- .../community-contributions/hopeogbons/python sample.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 week4/community-contributions/hopeogbons/python sample.py diff --git a/week4/community-contributions/hopeogbons/python sample.py b/week4/community-contributions/hopeogbons/python sample.py new file mode 100644 index 0000000..ba61e9c --- /dev/null +++ b/week4/community-contributions/hopeogbons/python sample.py @@ -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 \ No newline at end of file