Skip to content
Advertisement

How to iterate over nested list to input missing values

I have two objects, a variable (username), and a list (products) of products and costs

JavaScript

All prices are unique to each customer. Similarly, the product set is also unique to each customer, so I cant say take a specific index such as products[0] and it would always be ‘pr1’.

I’ve zipped the two objects together:

JavaScript

This gets me part way there, but I cant figure out how to append in the missing Products and ‘N/A’ for each username.

My end goal is a view that looks like this, dropping the ‘pr’ product keys so that I can use this to visualise the data:

JavaScript

Please help Python masters, I’ve been trying everything for hours and I’m all out of ideas..

Advertisement

Answer

you can try dict

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement