Hi im trying to write a function that opens a file and returns the total number of digits and single spaces it contains. The code isn't coming up with an error but in the doctests it is returning the wrong number.
def digit_space_count(filename):
file_in = open(filename)
text = file_in.read()
count = 0
for ch in text:
if ch.isspace():
count += 1
if ch.isdigit():
count += 1
file_in.close()
return count