Skip to content

Tag: python

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…

How to substract from each element in a matrix, with a condition

I have a matrix, and i don’t know the size, because the matrix was created from a dataframe. I have 2 arrays, min_cols and max_cols, first one is for each minimum from each column, and same with the max_cols. I want to recalculate each element from the columns, with this formula: Element[line][column] =…

convert 24 hour time (in string format) to time format

The time is given in string for eg “23:20”. However in my function I need to compare times for which I gotta convert these to time format I tried strptime() and it works with 12 hour format for eg when I enter “12:00PM” Answer For converting 24 hour format to a datetime.time object you…

Updating A List Word Counter

I’m creating a program that counts letters. I created two dictionaries that both have the same word and, because they are the same exact word, both have the same counter. I want to know how to merge the two dictionaries so that it updates the counters as well, but I consistently receive the result &#822…