title: Python: How can I count the number of files that appear in the output?
body: <p>I have a Python code that translates several html pages. After every page that was processed I direct the PRINT message to show me the name of the file and the message &quot;translated&quot;.</p>
  <p>Right now I get this PRINT message (Output):</p>
  <pre><code>true-value-of-myself.html translated
  I-love-books.html translated
  my-laptop-is-still-here.html translated
  </code></pre>
  <p><strong>But how can I count the number of files that appear in the output (filename) ? I need to change the OUTPUT so as to PRINT me something like this:</strong></p>
  <pre><code>true-value-of-myself.html translated (1)
  I-love-books.html translated (2)
  my-laptop-is-still-here.html translated (3)
  </code></pre>
  <p><strong>This is a piece of the code with the output:</strong></p>
  <pre><code>directory = os.fsencode(files_from_folder)
  
  def recursively_translate(node):
  
      for x in range(len(node.contents)):
  
          if isinstance(node.contents[x], str):
  
              if node.contents[x].strip() != '':
  
                  try:
  
                      node.contents[x].replaceWith(ts.translate(node.contents[x]))
  
                  except Exception as e:
  
                      print(e)
  
          elif node.contents[x] != None:
  
              recursively_translate(node.contents[x]) 
      .....
   
  for file in os.listdir(directory): 
      filename = os.fsdecode(file) 
      print(filename) 
   
  print(f'{filename} translated') 
  </code></pre>