title: AttributeError: 'list' object has no attribute 'endswith'
body: <p>I am trying to access a given folder, then access all of its sub folders (20+), and then access the only <code>xlsx</code> file inside of each sub folder to do some calculations.</p>
  
  <p>My code is using <code>load_workbook</code> from <code>openpyxl</code>. I need a for loop to read the existing files within the same folder, but these files change their name from sub folder to sub folder. To workaround the fact that <code>load_workbook</code> takes the precise name of the <code>xlsx</code> file as input, I opted for this solution:</p>
  
  <pre><code>filename=os.path.basename(file)
  wb=load_workbook(filename)
  </code></pre>
  
  <p>but it raises this error: <code>AttributeError: 'list' object has no attribute 'endswith'</code>. <strong>How to workaround my workaround?</strong></p>
  
  <p>My complete script:</p>
  
  <pre><code>import os
  from openpyxl import load_workbook
  
  directoryPath=r'C:\Users\MyName\Desktop\MyFolder'
  os.chdir(directoryPath)
  folder_list=os.listdir(directoryPath)
  for folders, sub_folders, file in os.walk(directoryPath):
      for name in file:
          if file.endswith(".xlsx"):
              filename=os.path.basename(file) #This is supposed to dump the name of the current file to a variable to be used by load_workbook
              wb=load_workbook(filename)
              cell_range = wb['A1':'A10'] #Accessing some cells
  
              #some calculations
  </code></pre>