PythiloLesson 7 of 32 · progress kept in this browser

Build permutations by fixing one item

A recursive function solves a problem by trusting a smaller copy of itself. To order n items, choose which item goes first, then ask for every ordering of the remaining items.

def count(n):
    return 1 if n <= 1 else n * count(n - 1)
print(count(4))   # 24 orderings
Your task

Write permutations(items) returning every ordering of items as a list of lists, in the order produced by choosing positions left to right.