First, install the add-apt-repository:
sudo apt-get update && sudo apt install software-properties-common && sudo apt update
Then, adding deadsnakes and updating
sudo add-apt-repository ppa:deadsnakes/ppa && sudo apt-get update
Verify package list
apt list | grep python3.10
Installing latest Python
sudo apt-get install python3.10
Adding Python versions to the list of alternatives
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
Configuring Python3 (Select the correct number, not Auto)
sudo update-alternatives --config python3
Finally testing version with python3 -V
Python3.9
sudo apt update && apt list | grep python3.9 && sudo apt-get install python3.9 && sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 3 && sudo update-alternatives --config python3
Select Python 3.9, then python3 -V