Y = range(1,32) lst_Y = list(Y) X = range(1,13) lst_X = list(X) result = -1 for i in lst_Y: y = lst_Y[i - 1] for n in lst_X: if n == y // 10 + y % 10: result = result + 1 print(result)