Skip to content

Instantly share code, notes, and snippets.

Created February 22, 2013 20:46
Show Gist options
  • Save anonymous/5016425 to your computer and use it in GitHub Desktop.
Save anonymous/5016425 to your computer and use it in GitHub Desktop.
Python function to return all pairs from a list as a list of tuples.
def all_pairs(list):
"""return all pairs from a list as a list of tuples"""
r = []
while len(list)>0:
i1 = list.pop()
for i2 in list:
r.append(tuple([i1,i2]))
return r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment