Skip to content

Tag: list

Sort one inside another

I have a class Person that contains names and hobbies. Then there’s a list that contains people. person1 = Person(“MarySmith”, [“dancing”, “biking”, “cooking”]) person2 = … people = [person1, person2,..] I need to return a list of people sorted alpha…

Repeatedly sample and combine elements of a list

Suppose we have a list L = [‘a’, ‘b’, ‘c’], I would like to perform a group sampling of L to generate an expected result: We can see, in this final output, a list of lists, its each element, there are no repeated elements without considering the order. How to implement it i…

How to use a dictionary to modify an array in python

I am trying to use a dictionary (created by reading the content of a first file) to modify the content of an array(created by reading the content of a second file) in order to return as many modified arrays as their are keys in the dictionary with the modification corresponding the position and change in the …

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:- i have another list of unique students as follows:- which i want to display student ranking based on their distinctions as follows:- What built in functions can be useful. I could not pose proper query on net. In o…

Return decimal fields from list

I have a generator which yields to datatype on is decimal and other is string i need the method to just return the decimal get_amount() now it is returning [(Decimal(‘1950.00′), ’06/16/2020’), (Decimal(‘4500.00′), ’06/16/2020’)] I want the list to be returned as…