Skip to content
Advertisement

Find max value of a column based on another in python

i have 2d list implementation as follows. It shows no. of times every student topped in exams:-

JavaScript

i have another list of unique students as follows:-

JavaScript

which i want to display student ranking based on their distinctions as follows:-

JavaScript

What built in functions can be useful. I could not pose proper query on net. In other words i need python equivalent of following queries:-

JavaScript

Advertisement

Answer

You define a dict base key of studentX and save the max value for each student key then sort the students_enrolled base max value of each key.

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement