Siemens interview question

Code for permutation using python