Turn string to a function in python

Is there a way to convert a string value to a function? If this simply isn’t doable with python, please let me know.

For example, I would like to convert this string:

'''
def greet(name):
    return f'Hello, {name}'
'''

to this function:

def greet(name):
    return f'Hello, {name}'

In a program, the example might look like:

function_string = '''
def greet(name):
    return f'Hello, {name}'
'''

def str_to_func(string):
    # Function body...

str_to_func(function_string)