def sumDigits(x): return sum(map(int, str(x))) cnt = 0 for m in range(1, 12 + 1): dd = 31 if m == 2: dd = 28 elif m in [4,6,9,11]: dd = 30 for d in range(1, dd + 1): cnt += (m == sumDigits(d)) print(cnt)