title: Delete item in a list using a for-loop
body: <p>I have an array with subjects and every subject has connected time. I want to compare every subjects in the list. If there are two of the same subjects, I want to add the times of both subjects, and also want to delete the second subject information (subject-name and time). </p>
  
  <p>But If I delete the item, the list become shorter, and I get an out-of-range-error. I tried to make the list shorter with using subjectlegth-1, but this also don't work.</p>
  
  <pre><code>   ...
     subjectlegth = 8
     for x in range(subjectlength):
          for y in range(subjectlength):
              if subject[x] == subject[y]:
                  if x != y:
                      #add
                      time[x] = time[x] + time[y]
                      #delete
                      del time[y]
                      del subject[y]
                      subjectlength = subjectlength - 1
  </code></pre>