How to write a program for permutations in python without itertools???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to write a program for permutations in python without itertools????

24th Nov 2019, 2:09 PM
Ashwinrema
2 Answers
+ 4
There a 2 ways to do it. Simple way is to use nested for loops. With 3 nested loops you can create samples that contains 3 digits. if you have to do it a more flexible way (e.g. 6 digits or 10 digits), you should use recursion.
24th Nov 2019, 3:33 PM
Lothar
Lothar - avatar
+ 2
If you go and look for the Python 3 Documentation on itertools, you'll see there is a python-written example for every function of the module. That way, you can see how the permutations generator is created, and create it yourself. Here is the link: https://docs.python.org/3/library/itertools.html
24th Nov 2019, 5:17 PM
Gonçalo Magalhaes
Gonçalo Magalhaes - avatar