1-Add the deadsnakes repository, which provides the latest Python versions, by running the following command:
xxxxxxxxxx
sudo add-apt-repository ppa:deadsnakes/ppa
2-Update the package list to include the new repository:
xxxxxxxxxx
sudo apt update
3-install python 3.10 :
xxxxxxxxxx
sudo apt install python3.10
4-Update the default Python 3 version to point to Python 3.10 by running the following command:
xxxxxxxxxx
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
5-Set Python 3.10 as the default version by running the following command and selecting Python 3.10:
xxxxxxxxxx
sudo update-alternatives --config python3
6-Finally, you can remove Python 3.8 to free up disk space by running the following command:
xxxxxxxxxx
sudo apt autoremove python3.8
I hope this helps
xxxxxxxxxx
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
xxxxxxxxxx
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update