def is_int(num): """Returns: True if num is of type int""" return type(num) == int def num_ints(the_list): """Returns: the number of ints in the_list Precondition: the_list is a list of any mix of types""" result = 0 for x in the_list: if type(x) == int: result = result+1 return result my_list = [3, 6, 7.0, "hi", 999] print("the list: "+str(my_list)) print("has "+str(num_ints(my_list))+" integers") print("\nLet's do that again! This time, with filter!") # collect just the integers from my_list int_list = list(filter(is_int, my_list)) # number of integers in the my_list is length of new list print("the list: "+str(my_list)) print("has "+str(len(int_list))+" integers")