The loop is working but once I put the if statements in it only prints I am a dir
If the if statements are not there I am able to print the dirpath, dirname, filename to the console
I am trying to list all the file names in a directory and get the MD5 sum.
from os import walk import hashlib import os path = "/home/Desktop/myfile" for (dirpath, dirname, filename) in walk(path): if os.path.isdir(dirpath): print("I am a dir") if os.path.isfile(dirpath): print(filename, hashlib.md5(open(filename, 'rb').read()).digest())