Last active
August 29, 2015 13:56
-
-
Save Jwpe/8950180 to your computer and use it in GitHub Desktop.
A Python script to separate leads into 'qualified' and 'unqualified' lists based on certain criteria
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let's return to our list of leads, but add some additional information | |
# that we can use to qualify them | |
leads = [ | |
{'first_name': 'Paul', 'last_name': 'McCartney', 'company': 'Beatles Inc.', | |
'title': 'Chief Marketing Officer', 'employees': 150, | |
'vertical': 'music'}, | |
{'first_name': 'Nina', 'last_name': 'Simone' , 'company': 'Jazz & Soul', | |
'title': 'CEO', 'employees': 350, 'vertical': 'music'}, | |
{'first_name': 'Michael', 'last_name': 'Jagger', | |
'company': 'Rolling Stone Corp', 'title': 'SVP Marketing', | |
'employees': 93, 'vertical': 'music'}, | |
{'first_name': 'Marilyn', 'last_name': 'Monroe', | |
'company': 'Hollywood Industries', 'title': 'CMO', 'employees': 200, | |
'vertical': 'movies'} | |
] | |
# We'll make an empty list of qualified and unqualified leads to sort our | |
# leads into | |
qualified = [] | |
unqualified = [] | |
# Next, we use another for loop to check each of our leads against certain | |
# criteria. | |
for lead in leads: | |
# For each lead, we use an 'if' statement to check if they should be | |
# qualified. We can use 'or' and 'and' statements to compare multiple | |
# things | |
if (lead['employees'] > 100 and lead['vertical'] == 'music' | |
and (lead['title'] == "CMO" or lead['title'] == "Chief Marketing Officer")): | |
# If the lead has more than 100 employees, is in the music vertical | |
# and has the title "CMO or Chief Marketing Officer", add them | |
# to the qualified list | |
qualified.append(lead['first_name']) | |
else: | |
# If the lead fails the qualifying test, add them to the unqualified | |
# list | |
unqualified.append(lead['first_name']) | |
# Now let's take a look at our qualified and unqualified lists: | |
print "Qualified: ", qualified | |
print "Unqualified: ", unqualified |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment