code: lst = ['hey','what',0,False,None,14] print(sum(x is not None for x in lst)) #output 5 参考:how-to-count-the-number-of-occurrences-of-none-in-a-list