get all the paths of files inside a directory python
<p>I am trying to retrieve all the files in a folder with a specific extension. But the problem is that I dont know how many sub-directories can be in there..</p>

<p>So basically something like:</p>

<pre><code>                   ------ filex.py
       ---folder1               -------- filezs.py
root             ------- folder2
       --- file.py              ----- fileabc.py
       --- file.txt
</code></pre>

<p>and so on</p>

<p>So basically I want to write a function which does the following:</p>

<pre><code> def get_files(root,files_of_type):
  return dict{key = file_name: value = path}
</code></pre>

<p>So for example if I want to get all the file and their path of extension py</p>

<p>then this will be like:</p>

<pre><code>  root = "/path/to/root"
  files_of_type = [".py"]

 returns  {"filex.py": "/path/to/root/folder1".. and so on}
</code></pre>

<p>Any suggestions
Thanks</p>
