title: getting the last index, better to use len(list)-1 or use own variable?
body: <p>In my code below, would it be better to use the i = len(scheduled_meetings)-1 or the i=0/i+=1 method? I know the cost of len() is O(1) and it's probably more clear whats going on this way, but it gets calculated for every m in sorted_meetings. i=0 is set once then only incremented if something is appended to the list. Will there even be a difference? Both methods work against my test cases, just wanted to get some feedback on which would be better.</p>
  
  <pre><code>import operator
  
  def answer(meetings):
      # sort by earliest end time
      sorted_meetings = sorted(meetings, key=operator.itemgetter(1))
      # always select the earilest end time
      scheduled_meetings = [sorted_meetings[0]]
      i = 0 #METHOD B
      for m in sorted_meetings:
          i = len(scheduled_meetings) - 1 #METHOD A
          if m[0] &gt;= scheduled_meetings[i][1] or m[1] &lt;= scheduled_meetings[i][0]:
              scheduled_meetings.append(m)
              i += 1 #METHOD B
  
      return len(scheduled_meetings)
  </code></pre>