Created
February 22, 2013 20:46
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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