I want to enforce that all items in a list are of type x. What would be the best way to do this? Currently I am doing an assert like the following:
a = [1,2,3,4,5]
assert len(a) == len([i for i in a if isinstance(i, int)])
Where int is the type I'm trying to enforce here. Is there a better way to do this?