Some struggle with recursion, but as package invocation\_tree visualizes the Python call tree in real-time, it gets easy to understand what is going on and to debug any remaining issues.
See this one-click Quick Sort demo in the Invocation Tree Web Debugger:
https://www.invocation-tree.com/#codeurl=https://raw.githubusercontent.com/bterwijn/invocation_tree/refs/heads/main/src/quick_sort.py×tep=0.5&play