Skip to content
Advertisement

Tag: dictionary-comprehension

How to look for specific values in a dictionary and return them properly

So I have a list dictionary of dictionaries (lst) that I’m trying to iterate through, compare values, and return the appropriate values. I have the following code to retrieve 2 arguments given from the command line, compare them through the dictionaries entries, and return the appropriate value: get_attribute_number(cmd1=sys.argv[1], cmd2=sys.argv[2], lst=data_list) However, my program is not returning anything. It is supposed

replace client’s id with their respective name in shipment dictionary using a loop and dictionary comprehension

d1={101:{‘Sender’:1,’Receiver’:3,’Start date’:’14-03-2020′,’Delivery date’:’25-03-2020′,’Sender location’:’Area 1′,’Receiver location’:’Area 6′,’Delivery status’:’Delivered’,’Shipping cost’:198}, 102:{‘Sender’:4,’Receiver’:1,’Start date’:’18-06-2020′,’Delivery date’:’09-07-2020′,’Sender location’:’Area 2′,’Receiver location’:’Area 4′,’Delivery status’:’Delivered’,’Shipping cost’:275}, 103:{‘Sender’:2,’Receiver’:3,’Start date’:’01-12-2020′,’Delivery date’:’Null’,’Sender location’:’Area 5′,’Receiver location’:’Area 1′,’Delivery status’:’In Transit’,’Shipping cost’:200}, 104:{‘Sender’:1,’Receiver’:5,’Start date’:’23-06-2020′,’Delivery date’:’25-06-2020′,’Sender location’:’Area 1′,’Receiver location’:’Area 4′,’Delivery status’:’Delivered’,’Shipping cost’:314}, 105:{‘Sender’:3,’Receiver’:4,’Start date’:’29-08-2020′,’Delivery date’:’10-09-2020′,’Sender location’:’Area 5′,’Receiver location’:’Area 3′,’Delivery status’:’Delivered’,’Shipping cost’:275}, 106:{‘Sender’:5,’Receiver’:2,’Start date’:’28-06-2020′,’Delivery date’:’Null’,’Sender location’:’Area 3′,’Receiver location’:’Area 1′,’Delivery status’:’In Transit’,’Shipping cost’:270}} d2 = {1:’Phillip’,2:’Omega lll’,3

Advertisement