0

I currently have a list of nodes (integers) saved in python, and a corresponding list of stress values (floats) also saved to a list in Python.

Using:

combined_list = list(zip(node_list, stress_list))
sorted_combined_list = sorted(combined_list, key=lambda x: x[0])

I now have a list of pairs, ordered by ascending node value with a corresponding stress value.

I am now trying to write these to a dictionary, where the nodes are the keys. To do this I have tried the following:

stress_dict = {}
for node, stress in sorted_combined_list:
    stress_dict[node] = stress

When I print stress_dict the output is what I would expect, with the exception that the first key value pair is a seemingly random node - the output looks as follows:

{40632320: 0.0, 2: 0.169, 3: 0.0, 4: ....}

Does anyone know what I may have missed, or why this is the case? Any help would be appreciated!

najusten
  • 59
  • 6

0 Answers0