How do you use a variable originally from a def function?

one way is to return it

e.g.

def func():
   variable = 3
   return variable

x = func()
print(x)

In this example, you call the function func() it does stuff and returns variable.
variable is assigned to x.