-2

I have a dictionary with one key "latest photos" and it has a lot of registers inside a list, each register is in a dictionary. How can I select only the first 3?

{'latest_photos': [{'id': 872121, 'sol': 3206, 'camera': {'id': 20, 'name': 'FHAZ', 'rover_id': 5, 'full_name': 'Front Hazard Avoidance Camera'}, 'img_src': 'https://mars.nasa.gov/msl-raw-images/proj/msl/redops/ods/surface/sol/03206/opgs/edr/fcam/FLB_682107210EDR_F0901732FHAZ00302M_.JPG', 'earth_date': '2021-08-13', 'rover': {'id': 5, 'name': 'Curiosity', 'landing_date': '2012-08-06', 'launch_date': '2011-11-26', 'status': 'active'}}, {'id': 872122, 'sol': 3206, 'camera': {'id': 20, 'name': 'FHAZ', 'rover_id': 5, 'full_name': 'Front Hazard Avoidance Camera'}, 'img_src': 'https://mars.nasa.gov/msl-raw-images/proj/msl/redops/ods/surface/sol/03206/opgs/edr/fcam/FRB_682107210EDR_F0901732FHAZ00302M_.JPG', 'earth_date': '2021-08-13', 'rover': {'id': 5, 'name': 'Curiosity', 'landing_date': '2012-08-06', 'launch_date': '2011-11-26', 'status': 'active'}}, {'id': 872123, 'sol': 3206, 'camera': {'id': 20, 'name': 'FHAZ', 'rover_id': 5, 'full_name': 'Front Hazard Avoidance Camera'}, 'img_src': 'https://mars.nasa.gov/msl-raw-images/proj/msl/redops/ods/surface/sol/03206/opgs/edr/fcam/FLB_682101393EDR_F0901708FHAZ00200M_.JPG', 'earth_date': '2021-08-13', 'rover': {'id': 5, 'name': 'Curiosity', 'landing_date': '2012-08-06', 'launch_date': '2011-11-26', 'status': 'active'}}]}

osint_alex
  • 952
  • 3
  • 16

1 Answers1

-1

You can do it like this:

data['latest_photos'][:3]
fulsiram
  • 27
  • 2