month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def happyday(m, d): dd = [0, 0] if d < 10: dd = [0, d] else: ds = str(d) dd = [int(d[0]), int(d[1])] return m == dd[0] + dd[1] cnt = 0 for i in range(1, 13): for j in range(1, month[i]+1): if happyday(i, j): cnt += 1 print cnt