#!/usr/bin/python3 import os file_list = os.listdir() for file in file_list: if os.path.isfile(file): print(file) else: print(file,'/', sep='') # go into that directory and do the same thing again # note - this is not the final answer for what we want to do, but it's a step in the right direction file_list2 = os.listdir(file) for file2 in file_list2: if os.path.isfile(file2): print(file,'/',file2) else: # go into that directory and do the same thing again print(file,'/',file2,sep='')