I built this little program to simulate 2 libraries I want to compare files with.
The code is this:
import os
path = "C:\Users\\nelson\Desktop\Lib Check"
pc_path = os.path.join(path, "pc")
phone_path = os.path.join(path, "phone")
pc_lib = [filename for path, dirname, filename in os.walk(pc_path)]
print pc_lib
it returns
[['1.txt', '2.txt', '3.txt', '4.txt', '5.txt', '6.txt', '8.txt', '9.txt']]
everything is fine except for the fact that the results are in a nested list. Why?
The only way I can stop this is by using
pc_lib = []
for path, dirname, filename in os.walk(pc_path):
pc_lib.extend(filename)