I’m trying to access data from a nested list and it is not working. I’m positive that my logic is wrong, but I don’t understand how. I’ll post the code below:
#Find the average of the birds counted
#Loop through list and parse out int
#Add integers together and count of each interger
#Divide integer sum by count
data_sites_and_birds_counted = [['A1', 28], ['A2', 32], ['A3', 1], ['A4', 0],
['A5', 10], ['A6', 22], ['A7', 30], ['A8', 19],
['B1', 145], ['B2', 27], ['B3', 36], ['B4', 25],
['B5', 9], ['B6', 38], ['B7', 21], ['B8', 12],
['C1', 122], ['C2', 87], ['C3', 36], ['C4', 3],
['D1', 0], ['D2', 5], ['D3', 55], ['D4', 62],
['D5', 98], ['D6', 32]]
birds = []
bird_count = 0
count = 0
for i in data_sites_and_birds_counted:
if type(i) == int:
bird_count = bird_count + data_sites_and_birds_counted[i]
count = count + 1
total = int(bird_count)/count
print(total)