title: Store output from for loop in an array
body: <p>I am still at the very beginning of my Python journey, so this question might be basic for more advanced programmers.</p>
  <p>I would like to analyse a bunch of .wav files, that are all stored in the same directory, so I created a list of all the filenames so I could then get their audiosignal and samplerate.</p>
  <pre><code>dirPath=r&quot;path_to_directory&quot;
  global files
  files = [f for f in os.listdir(dirPath) if os.path.isfile(os.path.join(dirPath, f)) and f.endswith(&quot;.wav&quot;)]
  for file_name in files:
      path_to_file= dirPath+&quot;\\&quot;+file_name
      audio_signal, sample_rate = sf.read(path_to_file)
  </code></pre>
  <p>with <code>sf</code> being the <code>soundfile</code> library.</p>
  <p><code>audio_signal</code> is an array, <code>sample_rate</code> is a number.</p>
  <p>Now I would like to be able to store both <code>audio_signal</code> and <code>sample_rate</code> together with the  corresponding <code>file_name</code>, so I can access them later. How do I do this?</p>
  <p>I tried</p>
  <pre><code>files = [f for f in os.listdir(dirPath) if os.path.isfile(os.path.join(dirPath, f)) and f.endswith(&quot;.wav&quot;)],[]
  for file_name in files[0]:
      path_to_file= dirPath+&quot;\\&quot;+file_name
      audio_signal, sample_rate = sf.read(path_to_file)
      files[1].append(audio_signal)
      files[2].append(sample_rate)
  </code></pre>
  <p>which seems to work, but is there a more elegant way? I feel like the <code>audio_signal</code>, <code>sample_rate</code> and <code>file_name</code> are individual values rather than codependent.</p>