def foo(): x = ‘hello world’ return x # return ‘hello world’ would do, too
foo()
print x # NameError - x is not defined outside the function
y = foo()
print y # this works
x = foo()
print x # this also works, and it's a completely different x than that inside
# foo()
z = bar(x) # of course, Now you can use x as you want
z = bar(foo()) # but you don't have to