I am trying to loop through 20 newsgroup dataset, at the end i join all the files under a variable called file_path. However, i am getting the following error at the next line :
name 'file_path' is not defined
import os
for (root,dirs,files) in os.walk(my_directory):
for special_file in files:
if special_file.endswith(''):
file_path = os.path.join(root, special_file)
What is my mistake? clearly i have defined file_path correctly.
file_path = os.path.join(root, special_file(isif special_file.endswith(''):your actual condition? That is always true for all strings).