use update-alternatives to change python3 version
Step 1. install python3.8 and python3.10
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.10
sudo apt install python3.8
Step 2. add python3.8 and python3.10 selection number in update-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
Step 3. use this command to change python3 version
sudo update-alternatives --config python3
Step 4. check python3 version
python3 -V