You can ask the user to input the name of the python file that contains the function definition and also ask for the name of the function. Then inside your main file you can do
import importlib
source = importlib.import_module(filename)
func = getattr(source, function)
like in this answer where function
is the name of your user function and then call the function from your main file. You can take user input as
filename = input("Please enter filename containing function")
However there's a security risk in this method as the user can input any function from the file this way (as noted in the comment below)