Jun-30-2021, 02:04 PM
p.map is giving you a list, so there is no reason to append unless you want Final_List to be a list of lists. Your code fails because FinalList[0] is ['10.0.0.1:Success', '10.0.0.2:Success', '10.0.0.3:Error', '10.0.0.4:Offline' , '10.0.0.5:Error'], not '10.0.0.1:Success' as you are expecting. Change the code to something like this:
Final_List = p.map(GetUplaudFies, Device_List)You can use a counter dictionary. But maybe it isn't right for this application since there are only 3 possible outcomes and they are all known. Your code should work with the above change. But this is a way to do it with a Counter
outcomes = [outcome.split(':')[1] for outcome in Final_List] outcomes = collections.Counter(outcomes) for item, count in counter.items(): print(item, count)