http://parsons.problemsolving.io/ is a really neat tool for creating Parsons Puzzles for Python (including indentation).
A catch is that the puzzle has to have a unique solution. If your function defines a couple of intermediate values that can be appear in either order, this is an issue.