#!/usr/bin/python import random lower_a = [\'a\', \'b\', \'c\', \'d\', \'e\', \'f\', \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\', \'o\', \'p\', \'q\', \'r
Take a look at function combinations in the module itertools (http://docs.python.org/library/itertools.html#itertools.combinations)
import itertools ... setup all ... for ilen in range(1, len(all)): for combo in itertools.combinations(all, ilen): print combo