title: Accessing the last element in a list in Python
body: <p>I have a list for example: list_a = [0,1,3,1]</p>
  
  <p>and I am trying to iterate through each number this loop, and if it hits the last "1" in the list, print "this is the last number in the list"</p>
  
  <p>since there are two 1's, what is a way to access the last 1 in the list?</p>
  
  <p>I tried:</p>
  
  <pre><code> if list_a[-1] == 1:
        print "this is the last"  
     else:
       # not the last
  </code></pre>
  
  <p>This does not work since the second element is also a 1.
  Tried:</p>
  
  <pre><code>if list_a.index(3) == list_a[i] is True:
     print "this is the last"
  </code></pre>
  
  <p>also did not work, since there are two 1's</p>