How to filter users in OKTA using their email and check if they already have the application they are requesting

Hello, anyone who can help me with Python scripts. I need to validate if the user is already existing in OKTA and if they are existing, i need to validate if a certain application (ex. oracle) is already assigned to them. If not, I need to assign them that application.

I am using import request btw.

Hope someone can help.