Changing default version of python from 2,7.16 to 3.12.1

my default py version changes back to 2.7.16 thou i have tried many ways it works till i close terminal but then jumps default version back to 2.7.16 can any one help me on this how to permanently change my default to python3

Are you a Windows user?

If so use the py.exe command to run python and configure py.exe by creating %LOCALAPPDATA%\py.ini

See 4. Using Python on Windows — Python 3.12.1 documentation for the details of what to write into the file.

sorry I should have mentioned I am using a mac mini late 2012 it has osx Catalina

Do you have /usr/local/bin on your PATH?
If you do just type python3 to run python3.12

i have both python 2.7.16 and 3.12.1 installed in my mac but later recent new version is not default indeed when ever i run a code in my machine terminal or visual studio code my code runs on the default version which is the older2.7.16 even my visual studio code is running the old 2.7.16 default on its inbuilt terminal. now I am guessing if i manage to make the changes in mac terminal it will change in my visual studio code terminal too.
so the change here to be made is i have to make my default version to python 3.12.1 so my codes can run on it in default or now I keep getting errors on python 2.7.16 as its unstable version for my mac osx Catalina
so I like to run my codes in default on the latest version python 3.12.1 so i get best results
now i know i can run python 3 by executing code after running the python3 in terminal command but i want default access to be the python3 file so i don’t have to execute python3 separately by command
like if i execute a py file now in default it is run by python2.7.16 unless i specifically execute python3 and the run the file
i hope my problem is explained well

The default python 3 version is run by typing python3.

If your scripts have a shebang line then make sure it refers to python3.
For example start the .py script lime this:

#!/usr/bin/env python3
print(“hello from python 3”)

Are you saying that you want python 3.12.1 to run when you type python? That is not common on macOS.

As for visual studio code you can configure the default it uses in its preferences I understand.

ok thanks a lot my problems no longer remains
thank you mr Barry Scott