Find all files in the current directory (maxdepth 1) with the extension .py and execute the command 'rename' to replace the extension with .txt in the same directory.
find ~ -maxdepth 1 -type f -name "*.py" -execdir rename 's/\.py/.txt/' {} \;