from rt import * ######################Problem 2########################### def filter_sum(s): """prec: s is a string postc: the total of all digits in the string is returned.""" out = 0 ## look at each char # if the cahr is a digit # add to running total #return total for ch in s: if ch in "0123456789": out += int(ch) return out def filter_sum(s): out = 0 for ch in s: if ch.isdigit(): out += int(ch) return out def filter_sum(s): return sum([int(k) for k in s if k in "0123456789"]) def filter_sum(s): return sum([int(k) for k in s if k.isdigit()]) def main(): print("*************** Problem 2 Tests **************") run_test(filter_sum, 10, ["c1o2w3s4moo"]) main()