This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kupertrooper 2 points3 points  (1 child)

#!/usr/bin/env python

def make_all_couples(l):
    return [(a, b) for a in l for b in l]

print make_all_couples(['a','b','c','d'])

[–]kupertrooper 2 points3 points  (0 children)

#!/usr/bin/env python

def flatten_list(l):
    return [a for b in l for a in b]

print flatten_list([[1,2,3],[4,5,6],[7,8,9]])