class Customer:
def __init__(self, cust_id, cust_name, location):
self.cust_id = cust_id
self.cust_name = cust_name
self.location = location
list_of_customers = [Customer(101, 'Mark', 'US'),
Customer(102, 'Jane', 'Japan'),
Customer(103, 'Kumar', 'India')]
dict_of_customer = {}
for customer in list_of_customers:
dict_of_customer[customer.location] = customer
print ("Customer name in India is "+dict_of_customer["India"].cust_name)
for key,value in dict_of_customer.items():
print ("Location: "+key+", Name: "+value.cust_name+", Id: "+(str(value.cust_id)))
Y2xhc3MgQ3VzdG9tZXI6CiAgICBkZWYgX19pbml0X18oc2VsZiwgY3VzdF9pZCwgY3VzdF9uYW1lLCBsb2NhdGlvbik6CiAgICAgICAgc2VsZi5jdXN0X2lkID0gY3VzdF9pZAogICAgICAgIHNlbGYuY3VzdF9uYW1lID0gY3VzdF9uYW1lCiAgICAgICAgc2VsZi5sb2NhdGlvbiA9IGxvY2F0aW9uCgpsaXN0X29mX2N1c3RvbWVycyA9IFtDdXN0b21lcigxMDEsICdNYXJrJywgJ1VTJyksCiAgICAgICAgICAgICAgICAgICAgIEN1c3RvbWVyKDEwMiwgJ0phbmUnLCAnSmFwYW4nKSwKICAgICAgICAgICAgICAgICAgICAgQ3VzdG9tZXIoMTAzLCAnS3VtYXInLCAnSW5kaWEnKV0KCmRpY3Rfb2ZfY3VzdG9tZXIgPSB7fQpmb3IgY3VzdG9tZXIgaW4gbGlzdF9vZl9jdXN0b21lcnM6CiAgICBkaWN0X29mX2N1c3RvbWVyW2N1c3RvbWVyLmxvY2F0aW9uXSA9IGN1c3RvbWVyCgpwcmludCAoIkN1c3RvbWVyIG5hbWUgaW4gSW5kaWEgaXMgIitkaWN0X29mX2N1c3RvbWVyWyJJbmRpYSJdLmN1c3RfbmFtZSkKCmZvciBrZXksdmFsdWUgaW4gZGljdF9vZl9jdXN0b21lci5pdGVtcygpOgogICAgcHJpbnQgKCJMb2NhdGlvbjogIitrZXkrIiwgTmFtZTogIit2YWx1ZS5jdXN0X25hbWUrIiwgSWQ6ICIrKHN0cih2YWx1ZS5jdXN0X2lkKSkp