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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.