0

# Permutations python

How do I write all the possible permutations of ABC? So AAA, AAB,AAC,ABC,ABB,... With and without the same letter in a fragment for example ABC, ACB, BAC, BCA, CAB, CBA,.. so without AAA etc

3 Answers

+ 2

from itertools import permutations
for each in permutations('abc', 3):
print(each)
there is a permutations function in the itertools standard library, no need to re-create the wheel
https://docs.python.org/3/library/itertools.html#itertools.permutations

+ 1

here I did something similar, you can change this code a bit and get what you need
https://code.sololearn.com/c5eOd7LLxyF4/?ref=app

0

Before I donât know how to change