Validating that all components required for an object to exist are present
<p>I need to write a script that gets a list of components from an external source and based on a pre-defined list it validates whether the service is complete. This is needed because the presence of a single component doesn't automatically imply that the service is present - some components are pre-installed even when there is no service. I've devised something really simple below, but I was wondering what is the intelligent way of doing this? There must be a cleaner, simpler way.</p>

<pre><code># Components that make up a complete service
serviceComponents = ['A','B']
# Input from JSON
data = ['B','A','C']
serviceComplete = True
for i in serviceComponents:
    if i in data:
        print 'yay ' + i + ' found from ' + ', '.join(service2)
    else:
        serviceComplete = False
        break
# If serviceComplete = True do blabla...
</code></pre>

<pre><code># Components that make up a complete service
serviceComponents = ['A','B']
# Input from JSON
data = ['B','A','C']
if all(item in data for item in serviceComponents):
    print("All required components are present")
</code></pre>

python