Attempting to get a count of filtered items while looping through the original list in Python will yield the count of the original list or the original index.
In other words if I want to query for "eggs" and "ham" in green, eggs, and, ham the index will be
2 eggs
4 ham
The count would be 4.
In order to obtain the index of items only based on the filtered list, or a count of the filtered list, perform actions on the output of the filtered list, not the original list.
pseudocode:
list=green,eggs,and,ham
filteredlist = filter list to return eggs, ham
filteredlist.index
filteredlist.count
The second approach gives me what I want:
1 eggs
2 ham
count: 2
This code is not pretty, but it has to be in bash for now which incorporates Python to do the above. It filters the larger list of AWS IP ranges down to the specific ranges I am seeking and grabs the index based on the second list to create a parameter name for each of the items returned.
https://github.com/tradichel/PacketCaptureAWS/blob/master/code/execute/get_s3_ips.sh