title: Looping over a list never sees the last element
body: <p>I do not know why, when I enter the <code>"apathetic"</code> mood, it just does not work.</p>
  
  <pre><code>'''
  Mood Assessment Application.
  '''
  
  #function to prompt the user to enter mood
  #and check to see whether the mood entered
  #is valid or not. allowed moods: (happy, sad, angry, apathetic)
  def getMood(message):
      moods = ['happy', 'sad', 'angry', 'apathetic']
  
      mood = ' '
      run = True
      while run:
          mood = input("Please enter mood: ")
          mood = mood.lower()
          for i in range(len(moods)-1):
              #print("%s == %s" % (mood, moods[i]))
              if mood == moods[i]:
                  run = False
                  break
      return mood
  
  #function to write mode to the moods.txt
  #file in append mode
  def writeMood(mood):
  
      myFile = open("moods.txt", "a")
      myFile.write(mood + "\n")
      myFile.close()
  
  #function to count for mood frequencies
  def moodFrequencies(moods):
      #['happy', 'sad', 'angry', 'apathetic']
      freq = [0, 0, 0, 0]
      i = 0
      s = len(moods) - 1
  
      #read the moods in reverse order
      #count last 7 or less
      while s &gt;= 0 and i &lt; 7:
          m = moods[s].lower()
          s -= 1
          i += 1
          #print(m)
          if m == 'happy':
              freq[0] += 1
          elif m == 'sad':
              freq[1] += 1
          elif m == 'angry':
              freq[2] += 1
          else:
              freq[3] += 1
      return freq
  
  #function to load all the moods into the list
  #return the list
  def loadMoods():
      myFile = open("moods.txt")
  
      moods = []
  
      for line in myFile:
          moods.append(line.strip())
  
      return moods
  
  #function to compute the average mood and display it
  def averageMood(f):
      #['happy', 'sad', 'angry', 'apathetic']
      total = (f[0] * 1) + (f[1] * 2) + (f[2] * 3) + (f[3] * 4)
      avg = int(total / 7)
  
      if avg == 1:
          print("You average mood is HAPPY")
      elif avg == 2:
          print("You average mood is SAD")
      elif avg == 3:
          print("You average mood is ANGRY")
      else:
          print("You average mood is APATHETIC")
  
  
  #main method
  def main():
  
      run = True
  
      #interact with the user and get the input for
      #mood
      while run:
          mood = getMood("Please Enter Your Mood Today: ")
  
          #write to the file
          writeMood(mood)
  
          #if the user want to enter more
          ch = input("\nWould you like to enter another? (y/n): ")
  
          #exit loop if he/she don't
          if ch.lower() == 'n':
              run = False
  
      #load moods
      moods = loadMoods()
  
      #calculate frequencies of the mood read from the file
      #['happy', 'sad', 'angry', 'apathetic']
      freq = moodFrequencies(moods)
  
      #average mood
      averageMood(freq)
      #print(freq)
      #mood diagnosis
      if freq[0] &gt;= 5:
          print("You are diagnosed as manic")
      elif freq[1] &gt;= 4:
          print("You are diagnosed as depressive")
      elif freq[3] &gt;= 6:
          print("You are diagnosed as schizoid")
  
  main()
  </code></pre>