is it possible to store a variable from a while loop to a function and then call that same variable from the function at the end of the loop
for eg:during while loop, p
As others have stated, there is probably a more suitable choice than this, but it might be convenient in some situations (perhaps in a REPL). Here's a simple function that does what you want with any number of values.
def store(*values):
store.values = values or store.values
return store.values
store.values = ()
>>> store(1, 2, 3)
>>> a, b, c = store()
>>> print a, b, c
1 2 3
>>> store(4, 5)
>>> a, b = store()
>>> print a, b
4 5