title: How to find a separate attribute among the records and form a separate collection on it?
body: <p>There is a class that contains the following information
  The name of the student, his group, grades in geometry, algebra and computer science</p>
  <pre><code>def __init__(self,surn,numbgroup,markgeometry,markalgebra,markinformatika):
            self.surn=surn
            self.numbgroup=numbgroup
            self.markgeometry=markgeometry
            self.markalgebra=markalgebra
            self.markinformatika=markinformatika
  </code></pre>
  <p>There are class objects, they are stored in the list - <code>studinfos []</code></p>
  <pre><code>(Surname, Group, grades in 3 subjects ())
  
  Smith ARP11 3,3,3
  Brown ARP12 4,5,3
  Jones ARP12 4,4,5
  Johnson ARP13 4,5,4
  Jensen ARP13 3,3,3
  Williams ARP13 5,5,5
  Adams ARP11 5,5,5
  Wilson ARP12 5,4,5
  Taylor ARP11 3,5,3
  Anderson ARP11 5,3,5
  </code></pre>
  <p>The problem is that I need to calculate the GPA from this collection for each group of these students.
  That is, from this collection I need to form separate collections by groups and separately calculate their average score. For example, like this:</p>
  <pre><code>Smith ARP11 3,3,3
  Adams ARP11 5,5,5
  Taylor ARP11 3,5,3
  Anderson ARP11 5,3,5
  
  Brown ARP12 4,5,3
  Jones ARP12 4,4,5
  Wilson ARP12 5,4,5
  
  Johnson ARP13 4,5,4
  Jensen ARP13 3,3,3
  Williams ARP13 5,5,5
  </code></pre>
  <p>How to calculate the average score in general, without dividing groups, I know how.
  But I cannot figure out how to divide them into separate lists into groups (<code>ARP11, ARP12, ARP13</code>) and work separately with each one. Moreover, there can be more than 3 groups.</p>
  <p><strong>What is already in stock:</strong></p>
  <p>A list that contains a tuple to store.
  True, the values in the tuple are immutable like, and here the question is how to fill it.</p>
  <pre><code>listgroup=[(student.numbgroup, 0)]
  </code></pre>
  <p>Function that is not fully implemented (it remains only to figure out the groups).
  Regarding the huge amount of <code>if</code>, please do not criticize, it correctly counts the number of evaluations. The <code>midlbal</code> variable itself is also working and tested. The sorted function separately also works.</p>
  <pre><code>def sortgroups(self):
            listgroup=[(student.numbgroup, 0)]
            countfour=0
            countfive=0
            counthree=0
            for student in studinfos:
                   if student.markgeometry==4:
                        countfour+=1
                   if student.markalgebra==4:
                        countfour+=1
                   if student.markinformatika==4:
                        countfour+=1
                   if student.markgeometry==5:
                        countfive+=1
                   if student.markalgebra==5:
                        countfive+=1
                   if student.markinformatika==5:
                        countfive+=1
                   if student.markgeometry==3:
                        counthree+=1
                   if student.markalgebra==3:
                        counthree+=1
                   if student.markinformatika==3:
                        counthree+=1
            for student in studinfos.numbofgroup[i]:
                    listgroup.append(get_numgroup)
                    midbal=((countfive+countfour+counthree)/3)
                    listgroup=[get_numbgroup(),midbal]
  </code></pre>