Siemens Interview Question

Code for permutation using python