Home » Python » python – How do I add multiple lists to a dictionary?-Exceptionshub

python – How do I add multiple lists to a dictionary?-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I have a list of n strings, and I have a list of n float values. The string has a corresponding value to it in the CSV file. I am needing to add the string as my ‘key’ and the floats as my ‘values’ in a single dictionary.
(the string and float list are the same length)

I was thinking about using a for loop to iterate through the CSV file then simply adding the ‘key’ to the current row[0] of the file. Then the same for the floats in row1. Yet, I keep getting a list index out of range error in the console log.

example of the CSV file

How to&Answers: