title: Get index of recently appended item
body: <p>Is there a straightforward way to get the index of an item I just appended to a list? I need to keep track of the last added item.</p>
  
  <p>I came up with two possible solutions:</p>
  
  <pre><code># Workaround 1
  # The last added is the one at index len(li) - 1
  &gt;&gt; li = ['a', 'b', 'c',]
  &gt;&gt; li.append('d')
  &gt;&gt; last_index = len(li) - 1
  &gt;&gt; last_item = li[len(li) - 1]
  
  # Workaround 2
  # Use of insert at index 0 so I know index of last added
  &gt;&gt; li = ['a', 'b', 'c',]
  &gt;&gt; li.insert(0, 'd')
  &gt;&gt; last_item = li[0]
  </code></pre>
  
  <p>Is there a trick to get the index of an appended item?</p>
  
  <p>If there's not, which of the above would you use and why? Any different workaround you suggest?</p>