0

I have this dictionary:

{'Francisco Partners': [45000000],
 'Bpifrance': [45000000, 15000000,87000000,15000000,...],
...}

I wrote this code to take it, go through each key and taking the max, median and min of the corresponding values (that are arrays)

srs = [["name", "max", "med", "min"]]

for key, value in dct:
    srs_row = []
    srs_row.append(key)
    srs_row.append(max(value))
    srs_row.append(median(value))
    srs_row.append(min(value))
    srs.append(srs_row)

When I run the program, I get this error, pointing to the "for ..." line:

ValueError: too many values to unpack (expected 2)

What does the machine tries to put in "value", if not an array ? Hence, is there a way to unload the values as an array, to iterate through after ?

Best,

TLP
  • 109
  • 9

1 Answers1

1

You need to use dictionary.items to iterate through dct

for key, value in dct.items():
   #Code
Devesh Kumar Singh
  • 20,259
  • 5
  • 21
  • 40