The purpose is just to create a dictionary with a path name, along with the file's SHA-256 hash.
I'm very new to Python, and have a feeling that there's a much better way to implement the following code. It works, I'd just like to clean it up a bit. fnamelst = [r'C:\file1.txt', r'C:\file2.txt']
[fname.replace('\\', '\\\\') for fname in fnamelst]
diction = [{fname: hashlib.sha256(open(fname, 'rb').read()).digest()} for fname in fnamelst]
for iter in range(0,len(fnamelst)):
dic2 = {fnamelst[iter]: hashlib.sha256(open(fnamelst[iter], 'rb').read()).digest()}
for
loop will overwritedic2
each time, instead of extending it. \$\endgroup\$