Use case
You have an actual name list you need to deploy software to through automated tool such as KACE by Quest software. You received a report no the number of people actually received the software and you need to know the actual percentage of software deployed.
Possible solution
set()
removes duplicates, and is unordered, we use set()
because we can use arithmetic operator to check the difference between two list.
actual_name_list_for_deployment = ['abc', 'cde', 'fgh', 'ijk', 'lmn'] deployed_name_list = ['abc', 'lmn'] diff = set(actual_name_list_for_deployment) - set(deployed_name_list) print('The list of people not deployed is {}'.format(diff)) print('The actual deployment is {}% of the {} people in the actual name list, {}% has not received the software'.format( str((len(deployed_name_list)/len(actual_name_list_for_deployment) * 100)), len(actual_name_list_for_deployment), str((len(diff)/len(actual_name_list_for_deployment))*100)))
Results
You can replace the static lists with the actual file by opening the files and store the file object to another variable and you can use set()
to create a pair of set object, minus the original list with the list reported by your server, then print out the percentage.