Nov-12-2021, 04:22 PM
(Nov-12-2021, 04:14 PM)bouraque7878 Wrote: What about if i want to product numbers out of the same digits without repition ?
I mean i don't want to product numbers like 1111, 1114, 1115 etc. I want to use a digit only once in a number.
Then you want "permutations". You need to make sure you only give it each digit one time or it will repeat it.
from itertools import permutations digits = "1457" for number_str in permutations(digits, 4): number = int("".join(number_str)) print(number)
Output:1457
1475
1547
1574
1745
1754
4157
4175
...