Joseph18 :
But a 7700K has a higher clock speed and better single core performance but the 8700 has more cores.
Actually, the i7-8700 can boost to higher clocks than the i7-7700K in its stock configuration. You can't just look at the base clocks, because the CPU should automatically boost to higher clock speeds as needed depending on how many cores are active, so long as temperatures remain reasonable. The base clocks don't actually matter a whole lot in practice. You can see a list of the boost clocks on wikipedia's pages for these processors...
i7-8700:
https://en.wikipedia.org/wiki/Coffee_Lake#List_of_Coffee_Lake_processors
i7-7700K:
https://en.wikipedia.org/wiki/Kaby_Lake#List_of_7th_generation_Kaby_Lake_processors
So, with a single core load, the 8700 can boost up to 4.6 GHz, while the 7700K can only boost up to 4.5 GHz at stock clocks. With additional cores active, the two processors can boost like so...
Code:
Cores | 1 | 2 | 3 | 4 | 5 | 6
8700 | 4.6 | 4.5 | 4.4 | 4.3 | 4.3 | 4.3
7700K | 4.5 | 4.4 | 4.4 | 4.4 | X | X
As you can see, their boost clocks are actually quite similar, with the 8700 actually able to boost slightly higher under lightly threaded loads. And since it has 50% more physical cores and threads, it can handle heavily-threaded workloads significantly better. Unlike the 7700K, it also comes will a stock cooler, although you may need to use a better cooler to get it to boost to its full potential.
The 7700K does have one advantage though, in that it is unlocked for overclocking for potentially better performance than at stock, provided you pair it with a Z-series motherboard and a capable third-party cooler. If you're not overclocking though, in general the 8700 will tend to be faster all around, being slightly faster in lightly threaded workloads, and significantly faster in heavily threaded workloads.
But are you planning to build a new system, or upgrade an existing one? The 8000-series processors require newer 300-series motherboards (Z370, B360, etc), which is something to keep in mind. What kind of hardware do you have now?