title: return length of file name in python (shell)
body: <p>I wanted to write a Python Script that lists all files in the current working directory, if the <strong>length</strong> of a file's name is between 3 - 6 characters long. Also, it should only list files with the extension <code>.py</code> </p>
  
  <p>I was not able to find any specific function that would return the legnth of a files name, only the size of its contet. </p>
  
  <p>Here is what my code looks like so far: </p>
  
  <pre><code>#!/usr/bin/env python3
  import os
  
  for file in os.listdir(os.getcwd()):
      if file.endswith(".py"):
          print(file)
  </code></pre>
  
  <p>Can anyone tell me what the solution could look like? Do I use a RegEx in the <code>os.getcwd(RegEx)</code> function? </p>
  
  <p><strong>edit:</strong></p>
  
  <p>I am sorry for posting this trivial question. I found the solution and it looks as followed: </p>
  
  <pre><code>#!/usr/bin/env python3
  import os
  
  for file in os.listdir(os.getcwd()):
      if file.endswith(".py"):
          if ((len(os.path.splitext(file)[0])) &gt; 2 and (len(os.path.splitext(file)[0])) &lt; 7):
              print(file)
  </code></pre>
  
  <p>This works for my intended purpose. Thanks for the answers, they made me realize that using len(filename) was an option and therefore my question was not very smart. </p>