Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def consec_combos(ls):
- combos = []
- for i in xrange(len(ls)):
- for j in xrange(i, len(ls)):
- combos.append(ls[i:j+1])
- return combos
- print consec_combos('12,25,28,32,36'.split(','))
- OUTPUT: [['12'], ['12', '25'], ['12', '25', '28'], ['12', '25', '28', '32'], ['12', '25', '28', '32', '36'], ['25'], ['25', '28'], ['25', '28', '32'], ['25', '28', '32', '36'], ['28'], ['28', '32'], ['28', '32', '36'], ['32'], ['32', '36'], ['36']]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement