title: FFMPEG python check if dictionary key exists
body: <p>I want to check if there is a dictionary key: <code>&quot;data[&quot;streams&quot;][1][&quot;codec_name&quot;]&quot;</code> and if there is one to print the values of couple of keys and if not to print &quot;No Audio&quot;. Actually if there is no audio the whole data[&quot;streams&quot;][1] is missing. Right now the script is always returning No Audio even if the audio exists. What I am doing wrong?</p>
  <pre><code>#!/usr/bin/env python
  import subprocess
  import json
  
  input_file = raw_input(&quot;Please enter the input file path: &quot;)
  
  returned_data = subprocess.check_output(['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', input_file])
  data = json.loads(returned_data.decode('utf-8'))
  print &quot;==========================Audio=============================&quot;
  if 'data[&quot;streams&quot;][1][&quot;codec_name&quot;]' in data:
          print &quot;Codec: %s&quot; %(data[&quot;streams&quot;][1][&quot;codec_name&quot;])
          print &quot;Sample Rate: %.3f KHz&quot; %(int(data[&quot;streams&quot;][1][&quot;sample_rate&quot;])/1000)
          print &quot;Bitrate: %d Kbps&quot; %(int(data[&quot;streams&quot;][1][&quot;bit_rate&quot;])/1000)
  else:
          print &quot;NO AUDIO&quot;
  </code></pre>