import os


def make_chapter_files():
    os.chdir('../static/images')

    for _, dirs, files in os.walk(os.getcwd()):

        dirs = [d for d in dirs if not d[0] == '.']
        files = [f for f in files if not f[0] == '.']

        for directory in dirs:
            file_path = get_filepath(directory)
            make_file(file_path)


def write_chapter_files():
    os.chdir('../static/images')

    root, chapters, files = next(os.walk(os.getcwd()))
    for chapter in chapters:
        path_list.append(os.path.join(root, chapter))
    path_list = [p for p in chapters]
    chapter_list = [name for name in files if not name[0] == '.']
    print path_list
    # print chapter_list


def get_filepath(directory):
    filepath = '{}.txt'.format(directory)
    return filepath


def make_file(filepath):
    f = open(filepath, 'a')
    f.close()

if __name__ == '__main__':
    # make_chapter_files()
    write_chapter_files()

@@ -455,41 +455,9 @@
 )))%0A
-    for chapter in chapters:%0A    
+%0A
     
@@ -469,16 +469,12 @@
 list
-.append(
+ = %5B
 os.p
@@ -500,34 +500,20 @@
 ter)
-)%0A    path_list = %5Bp for p
+ for chapter
  in 
@@ -584,24 +584,25 @@
 %5B0%5D == '.'%5D%0A
+%0A
     print pa
@@ -609,21 +609,19 @@
 th_list%0A
+
    
- #
  print c

Fix list comprehension