Accessing Secrets by Non Environment Index

I have a scenario where I have secrets created for (ID & Key) various AWS accounts in the format AWS_{ACC_ID}ACCESS_KEY_ID & AWS{ACC_ID}_ACCESS_KEY. The various accounts are provided in a Yaml file which is an input to a GitHub action. Now, I should be able to retrieve these secrets based on the Account IDs. For this, I use Python to read the Yaml and get the account IDs and store them in Python variables. But I am not sure how to get the secrets. For example, ${{ secrets[“ACC_ID_STORED_IN_PYTHON_VARIABLE”] }}. Even if I put the Account IDs into environment variables, they will be dynamic. Unfortunately, I don’t think there is a way to access env variables using the syntax env[“ACC_ID_STORED_IN_PYTHON_VARIABLE”] so that I could have then used this variable for accessing the secret. I hope I have made my requirement clear. Can anyone please help? Since Secrets, ENV are specific to GitHub, I am not sure how to retrieve them using Python Variables as Indexes.