title: How to find the sum of elements located at odd indices in Python
body: <p>I know a similar question has been asked here before, but mine is slightly different. I want to write a function that takes a list of positive integers and returns the sum of the elements located at the odd indices. The catch is, I want to use only a for loop or a while loop.
  Here's what I have so far:</p>
  
  <pre><code>def getSumOdds(aList):
  for i in range(0, len(aList)):
      if i%2 == 0:
          pass
      if i%2 != 0:
          sum = sum + aList[i]
          return sum
  </code></pre>
  
  <p>However, when I enter this code into Python, I get an error saying builtins.UnboundLocalError: local variable 'sum' referenced before assignment. Does anyone know a better way to find the sum or how to fix the error message? Thanks in advance.</p>