Devang Devang - 1 year ago 70
Python Question

Python permutations in order

listA = ["A","B","C","D"]

From this, I want the following output only:


I have looked at various questions on permutations here, but I am not able to do achieve this so far. Any help will be appreciated.

Answer Source

another way to do this - brute force,

def permutation(L):
    for i in range(len(L)):
        x = L[i:i+3]
        length = len(x)
        if length != 3:
            x = x + L[:3-length]

L = ["A","B","C","D"]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download