Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do i display only certain part of a dictionary?

I have a dictionary with multiple keys but I only need to print part of it, i don’t know how to do it though.

The output i have for my dictionary is:

[{'vin': '4T1R11AK7NU637019', 'askPrice': 28106.0, 'msrp': 28106.0, 'mileage': 0.0, 'isNew': True,
 'firstSeen': '2021-11-28', 'lastSeen': '2021-11-28', 'modelName': 'CAMRY', 'brandName': 'TOYOTA', 'year': 2022.0,
 'dealerID': 30873, 'color': 'Celestial Silver Metallic', 'interiorColor': 'Black', 'vinDecode': {(A LOT OF THINGS IN HERE}}},

 {'vin': '4T1G31AK7NU45B292', 'askPrice': 0.0, 'msrp': 0.0, 'mileage': 0.0, 'isNew': True,
  'firstSeen': '2021-11-28', 'lastSeen': '2021-11-28', 'modelName': 'CAMRY', 'brandName': 'TOYOTA', 'year': 2022.0,
  'dealerID': 12750, 'color': 'N/A', 'interiorColor': 'N/A', 'vinDecode': {(A LOT OF THINGS IN HERE}}}]

So there are multiple vins and i would just like to print from vin to interiorColor for every entry; completely ignoring the vinDecode part. Is there any way I could do it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use .pop() on the dictionary to remove data:

for item in items:
    item.pop("vinDecode")
    print(item)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading