# How do you write a python\pseudo code that generates all pair permutations?

What would be a good pseudo code or Python 3 code for the following permutations problem? Let us define a n-permutation as a bijective function $$\pi: \{0,…,n-1\}\rightarrow \{0,…,n-1\}$$ and represent it using a list, meaning that $$\pi(i)=j$$ iff list[i]=j. Let us also define a pair permutation as a permutation in which for every $$i\neq j , \thinspace \pi(i)=j \Leftrightarrow \pi(j)=i$$ . I need to write a recursive function code, that takes an interger n, and generates all n-pair permutations (every permutation appears, and only once). [This question appeared on a test, that it’s solution remains confidential 🙁 ]