Skip to content
Advertisement

Turning a list into a dictionary adding headers

I’d like to turn the following list in a dictionary:

JavaScript

I’d like to add the following headers. Each element of the list needs to have its own header.

JavaScript

This is my code:

JavaScript

And the following is my output. I obtain the dictionary only for the first element of the list and I can’t understand why.

JavaScript

Advertisement

Answer

the line

JavaScript

only take the first element.

To take all element, you can do :

JavaScript

witch output :

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