def permutations(L):
    if len(L) == 0:
        return [()]
    else:
        P = permutations(L[1:])
        return [p[:i] + (L[0],) + p[i:] for p in P for i in range(len(L))]
 
