1-Add the deadsnakes repository, which provides the latest Python versions, by running the following command:
2-Update the package list to include the new repository:
3-install python 3.10 :
4-Update the default Python 3 version to point to Python 3.10 by running the following command:
5-Set Python 3.10 as the default version by running the following command and selecting Python 3.10:
6-Finally, you can remove Python 3.8 to free up disk space by running the following command:
I hope this helps