Using the keyword "global", you can change the scope of a variable from local to global, and then you can access it outside the function.
E.g.
The following code will print v =25 although the print statement is outside the function.
def myfun1():
global v
v = 25
myfun1()
print(v)