Parse dictionary looking for a specific string
<p>I'm writing a python script to make an API call to our Cisco ASA firewall and the information returned from the firewall is placed into a dictionary. I then need to parse through this dictionary looking for a specific string. The problem is, there's 1 key and what looks to be one large value. I've inserted an example of the output I receive from the firewall. </p>

<blockquote>
  <p>{u'response': [u'object-group network
  ng-enc-incoming-ftp-outside\nnetwork-object 1.1.1.1 255.255.255.128\n
  network-object host 2.2.2.2\n network-object host 3.3.3.3\n
  network-object host 4.4.4.4\n network-object host 5.5.5.5]}</p>
</blockquote>

<p>Ideally, I would like to search this output looking for a specific IP and if that IP was present, present a message indicating as much. I can't seem to find a good way to parse through a really long value looking for a specific text string.  </p>

<p>If you only want to know whether or not a specific IP is in the response string, you can use the <code>in</code> operator:</p>

<pre><code>if '2.2.2.2' in resp_dict['response'][0]:
    print('Found')
</code></pre>

<p>Or generalized:</p>

<pre><code>ip = '2.2.2.2'
if ip in resp_dict['response'][0]:
    print('{} found'.format(ip))
</code></pre>

python dictionary networking