title: Python Loop Equivalent Excel Offset equivalent?
body: <p>I am new to programming in Python and am trying to write a <strong>For/While</strong> loop that returns a value relative to another in a list based on the current value in the loop. The closest analog from excel I can think of is the OFFSET function, but my searches have failed to come up with an answer. Also, I believe VBA in excel allows you to use relative cells instead of absolute. Maybe this is a better analog.</p>
  <p>As an example:</p>
  <p>Suppose I have a simple list <code>abc = [2,5,21,54,23,12,23]</code> and I want to create a variable that is the current value in the loop divided by the prior value. So in this instance <code>5</code> would be divided by <code>2, 21</code> divided by <code>5</code>, etc.</p>
  <p>An example of the code would like something like:</p>
  <pre><code>for val in abc:
       xyz = val/val[-1]
       print(xyz)
  </code></pre>
  <p>I understand I would need to write an exception for the first iteration and the syntax is incorrect, but just trying to convey my message.</p>
  <p>My search found that pandas has an ability to do this, but I was wanting to know if it is possible to do without pandas. Would appreciate any input.</p>