title: Access two consecutive elements of a list in Python
body: <p>I need to access the <code>n</code> and <code>n+1</code> elements of a list. For example, if my list was <code>[1,2,3,4,5]</code> and my nth element was <code>2</code>, I'd need the next element in the list, <code>3</code>.</p>
  
  <p>Specifically, I need to access these elements in order to use them to look up a value in a matrix A</p>
  
  <p>I have a for loop that's iterating over the list:</p>
  
  <pre><code>list = [1,2,3,4,5]
  
  for i in list:
    value = A[i,i+1] #access A[1,2], A[2,3], A[3,4], A[4,5]
  </code></pre>
  
  <p>the problem with this is that I can't do an <code>i+1</code> operation to access the <code>n+1</code> element of my list. This is my first time programming in Python and I assumed element access would be the same as in C/C++ but it's not. Any help would be appreciated.</p>