fork download
  1. import itertools
  2.  
  3. if __name__ == '__main__':
  4. l = ['a', 'b', 'c', 'd', 'e']
  5. m = ['A', 'B', 'C']
  6. with open("sample.csv", 'w') as f:
  7. for n in range(1, len(l)):
  8. element = list(itertools.combinations(l, n))
  9. for a in itertools.product(m, element):
  10. output = ','.join(x for b in a for x in b)
  11. print(output)
  12. f.write(output + '\n')
  13.  
Runtime error #stdin #stdout #stderr 0.1s 10104KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 6, in <module>
IOError: [Errno 13] Permission denied: 'sample.csv'