title: Method for using variable (result from loop) in same function
body: <p>I don't know how to phrase this, but my current structure uses recursion. So I call upon the same function when the looping within the function is finished, and use the results of the loop as an argument to continue the program with new data to work through.</p>
  
  <p>So this function of mine spits out a number, among other things. I've assigned this resulting number from the function to a variable.</p>
  
  <p>My gap in knowledge is however coming up short on the thought process/logic to a solution. Although it sounds simple. I've thought about maybe a way to over ride the original information with a global variable of the same name, but that doesn't seem to over ride it since at the top of the function is the variable declaration. I've also thought about using arguments with the *args method. But that isn't working either. </p>
  
  <p>My function, has a loop in it. That requires variable X for example. On the loops first run, X already has a base number to work with. This X is used in the loop as part of the equation, after all the loops run through, I get a result and assign that to variable Y. </p>
  
  <p>I need to essentially add Y to X, essentially making X = X + Y and then recall the function. </p>
  
  <p>Trying this line of thinking, and declaring an updated variable doesn't work with this method because when I recall the function, it updates it to the base number again. </p>
  
  <p>I've also explored if statements checking if the number is X and declaring the updated variable in the else statement otherwise. But that too is not providing a fruitful outcome. </p>
  
  <p>What line of thinking, or method should I be applying to solve this problem?</p>
  
  <p>I can explain more if necessary, me being a new to Python I've come up short on the search for the answer before posting, maybe because I don't know the terminology for this type of method to find such answers. </p>
  
  <p>I appreciate your time in reading this, thanks!</p>
  
  <pre><code>def loop1Yo(f):
      matrixDict = {}
      timer = 0
      x = f[0]
      for element in f[1:]:
          depTime = 1479215120 + xyzDuration ###(This part wouldnt work but I think explains what I am trying to do.)
          directionResult = (depTime) + (element)
  
  sortedMatrixList = sorted(matrixDict.items(), key=operator.itemgetter(1))
  xyz = sortedMatrixList
  xyzDuration = sortedMatrixList[0][1]
  
  f = [x for x,_ in xyz]
  print (f)
  
  loop1Yo(f)
  </code></pre>