How to store a result of a function in Python to use it later?

I’m having trouble returning the value of a variable ‘test’ from a function so that I can use it elsewhere. I’ve tried using ‘return’, but when I try to use the variable in another function, I get a ‘NameError’. What can I do to solve this issue? Attaching code snippet:

def functn():
    x = 'This is a function'