# 3 examples of 'python permute list' in Python

Every line of 'python permute list' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

## All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
``54def permute(l):55    """56    Return all possible permutations of l.5758    @type l: sequence59    @rtype: a list of sequences60    """61    if len(l) == 1:62        return [l,]6364    res = []65    for i in range(len(l)):66        l2 = list(l[:])67        x = l2.pop(i)68        for l3 in permute(l2):69            l3.append(x)70            res.append(l3)7172    return res``
``52@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 4, 5, 6)])53def test_permute_list():54    return Permute([0, 4, 1, 3, 2])``
``6def permute(a):7    """8    Creates all unique combinations of a list a that is passed in.9    Function is based off of a function written by John Lettman:10    TCHS Computer Information Systems.  My thanks to him.11    """1213    a.sort() # Sort.1415    ## Output the first input sorted.16    yield list(a)1718    i = 019    first = 020    alen = len(a)2122    ## "alen" could also be used for the reference to the last element.2324    while(True):25        i = alen - 12627        while(True):28            i -= 1 # i--2930            if(a[i] < a[(i + 1)]):31                j = alen - 13233                while(not (a[i] < a[j])): j -= 1 # j--3435                a[i], a[j] = a[j], a[i] # swap(a[j], a[i])36                t = a[(i + 1):alen]37                t.reverse()38                a[(i + 1):alen] = t3940                # Output current.41                yield list(a)4243                break # next.4445            if(i == first):46                a.reverse()4748                # yield list(a)49                return``