Statistical queries on a list of customers
If you need to do more data analysis on this afterwards, then this might be a good time to learn about pandas which has data frames, allowing you to modify whole records at a time.

First, read in your list into a data frame:

import pandas as pd

df = pd.DataFrame([[customer.active, customer.age, customer.gender]
                   for customer in filter(None, customers)],
                  columns=["active", "age", "gender"])


Here the filter(None, it) filters out all None values (and all falsey values, but an object that exists is by default truthy, so unless you overwrote Customer.__eq__ or Customer.__bool__, it should be fine).

Now we have a data frame like this:

print(df)
#   active   age gender
# 0   True  38.0      F
# 1  False  18.0      M
# 2  False   NaN      F
# 3   None  64.0   None
# 4   True  23.0   None
# 5   None  23.0      M


To make handling of the left over None values easier, we replace them with numpy.nan:

import numpy as np

df = df.replace([None], np.nan)
print(df)
#   active   age gender
# 0   True  38.0      F
# 1  False   NaN      M
# 2  False   NaN      F
# 3    NaN  64.0    NaN
# 4   True  23.0    NaN
# 5    NaN  23.0      M


Now to get to your tasks:


Number of active customers:

active_users = df.active.sum()
# 2

Number of inactive customers:

deleted_users = sum(customer is None for customer in customers)
inactive_users = len(df) + deleted_users - active_users
# 8

Any customer deleted:

deleted_users &gt; 0
# True

Any customer with active=None:

df.active.isna().any()
# True

Average of male customers (NaNs are automatically ignored):

df[df.gender == "M"].age.mean()
# 20.5



If there are no people of that gender, it will return a numpy.nan instead of 0, though:

df[df.gender == "X"].age.mean()
# nan




From there on you can also do more fancy stuff:


Average age per gender:

df.groupby("gender").age.mean()
# gender
# F    38.0
# M    20.5
# Name: age, dtype: float64



Using this makes your code both more efficient to write (since most things you could want to do are already implemented) as well as faster to run (since the methods are usually implemented in C, instead of running in Python. So if you have lots of customers, this will certainly be better.