Jun-03-2020, 07:40 PM
this is weird file format.
you can do something like
you can do something like
from ast import literal_eval with open(path_to_your_file) as f: for line in f: name, values = line.split(' = ') values = literal_eval(values) print(f"The sum of {name} is {sum(values)}")of course, instead of ast.literal_eval, you can parse the list yourself, i.e. after the split at =, you can remove the brackets, split at comma, convert numbers to int, and so on...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs