Skip to content

Tag: dictionary

Get latest timestamp from list of dictionaries

I have list of dictionaries that I am pulling from a ticketing system. Each dictionary contains the name and timestamp of a ticket. There are cases where multiple tickets are entered for the same user and I would like to filter this list to only append the ‘latest’ timestamp to the list, rather th…

Comparing nested dictionaries into general dictionary

I would like to compare multiple nested dictionaries inside a larger dictionary. Suppose we have the following dictionary: I have a pricesDict that contains the prices of some products (more than 3 as shown above) in different supermarkets (more than 4 as shown above). I want to go through it to compare the n…

print python dictionary in particular style

How to print a Python dictionary in this given pattern. I was asked this question in an interview and I couldn’t solve it. Input dictionary: Desired output: Answer Here’s a quick recursive solution: Since each “level” of the dict is built from the next level down, it’s easier to …

How to order dictionary based column?

I have a column that contains dictionary like below I need to write a Python code to sort each element in a column based on a value such as output will be like Can someone help with that please? I tried sorted function but it breaks at some point. Thank you! Answer I assume that Column_1 is a list:

Python, how to sort this dictionary right?

I started 100 days of code and this project is a silent auction (day 9). You take a user’s name and bid price, store it in a dictionary, and then clear it (prompting to see if there are other users). The whole point is to collect the keys/values (that are unknown) and sort them so that it prints the hig…