this is the only solution I found in the web which works. Strangely it is hard to find...
https://techviewleo.com/how-to-install-python-on-amazon-linux/
or you to install 3.8 on Amazon Linux 2, you need to have amazon-linux-extras repository installed.
$ which amazon-linux-extras
/usr/bin/amazon-linux-extras
If the command doesn’t return any output, then install the package that will configure the repository:
sudo yum install -y amazon-linux-extras
Confirm if you can see Python 3.8 packages available on the repository.
$ amazon-linux-extras | grep -i python
python3.8 available [ =stable ]
As can be seen from the output python3.8 package is available for installation.
Enable the repository before using it.
sudo amazon-linux-extras enable python3.8
Issue the commands shown below in the terminal to install Python 3.8 on Amazon Linux 2 server.
sudo yum install python3.8