for filename in dirname:
enumerates individual characters in dirname
string. Try:
#!/usr/bin/env python
import os
topdir = r'E:\Grad\LIS\LIS590 Text mining\Part1\Part1'
matches = []
for root, dirnames, filenames in os.walk(topdir):
for filename in filenames:
if filename.endswith(('.txt','.html','.pdf')):
matches.append(os.path.join(root, filename))
print("\n".join(matches))
You don't need the for
-loop with dirnames
here.