The Core i7 has 4 cores, 8 threads (which is called hyperthreading, the extra threads sorta act like cores, but not exactly) and so does the Ryzen 5. The Ryzen 5 1500x is a better idea if you can afford it because it supports DDR4 and newer technologies like usb 3.1 and you can likely upgrade it in the future. Getting more cores is a good idea if you do heavy photo editing or rendering or CAD, and most people can get by on a quad for most tasks.
However, if you have the motherboard and parts to support it, and it would be cheaper, you might as well go with the i7 because although there is a difference in performance; the Ryzen is faster, but maybe not enough to justify doing a completely new build.
What are your specs right now?