title: Creating lists of files using os.listdir()
body: <p>I know that I can create a list of the interior of a given directory using os.listdir(path), but what if I want to know what is inside of directories that themselves are inside the directory specified in "path"?</p>
  
  <p>I have one main directory that contains 25 directories; each of those directories contain 30 more directories, and inside each of THOSE directories there are 3-10 files that need to be read into my script. So far I've tried to create lists of lists to document all the directories but it's spiraling out of control very quickly:</p>
  
  <pre><code>list = os.listdir(path)   # Path to the main directory
  newList = []
  for i in range(len(list)):
      newList.append(path + list[i])   # I modify the path so the next os.listdir command
                                       # finds the correct directory
  
  list1 = []
  for i in range(len(newList)):
      list1.append(os.listdir(newList[i]))    # Create a new list of lists for first set
                                              # of interior directories
  list2 = []
  for i in range(len(list1)):
      for j in range(len(list1[i])):
          list2.append(os.listdir(list1[i][j]))   # I'm encountering an error here
  </code></pre>
  
  <p>Is there a command I can use that will do all this work for me? I'm looking for something that, given a path, will return all contents of all directories inside it. Any suggestions are appreciated.</p>