import datetime as dt count = 0 date = dt.datetime(2015,1,1,0,0) for i in range(365): a = sum(map(int,list(str(date.month)))) b = sum(map(int,list(str(date.day)))) if a==b: count+=1 date+=dt.timedelta(days=1) print(count)