title: Sum the elements in a list that contains string and integer and put the answer in another list python
body: <p>I have to write a code to sum the grades of each student in the list and return the total.
  My code is:</p>
  
  <pre><code>list=['student1',10,20,40,'student2',20,20,40,'student3',20,30,40,'student4',20,10,30]
  list2=[]
  for i in range(0,len(list1),4):
      list2.append(list1[i])
      for j in range(len(list1)):
          if j%4 == 1:
              sum= list1[j]+list1[j+1]+list1[j+2]
              list2.append(sum)
  print(list2)
  </code></pre>
  
  <p>the expected output should be like:</p>
  
  <pre><code>['student1', 70, 'student2', 80,'student3', 90, 'student4', 60]
  </code></pre>
  
  <p>but i got this output:</p>
  
  <pre><code>['student1', 70, 80, 90, 60, 'student2', 70, 80, 90, 60, 'student3', 70, 80, 90, 60, 'student4', 70, 80, 90, 60]
  </code></pre>
  
  <p>​</p>
  
  <p>so what is the wrong with my code?</p>
  
  <p>​</p>