Which is more basic: 1,2‐dihydropyridine or 1,4‐dihydropyridine?
In compound $\ce{A}$ , lone pair on $\ce{N}$ is in conjugation with two $\ce pi$ bonds (as shown below). Therefore this lone pair is delocalized (resonance structures in the figure below) to a greater extent.

In  compound $\ce{B}$ , lone pair on $\ce{N}$ is in conjugation with a single $\ce pi$ bond , while the other pi bond is not in conjugation or is cross conjugated.

Since lone pair on $\ce{N}$ in compound $\ce{B}$ is less delocalized then in compound $\ce{A}$ , compound $\ce{B}$ is more basic then compound $\ce{A}$.