the i5-8400 has a faster multi-core speed, but the i3-8350k has a *slightly* better single-core speed.
I'd go with the i5-8400 because even though it is slightly slower at single core, the multi-core performance can really affect your experience nowadays.
Also, the fact that it only costs a few bucks more than the i3-8350k makes it more appealing to go with the i5-8400.
and last but not least: the fact that the i3-8350k is unlocked doesn't matter that much unless you are really looking to overclock it.
overclocking when gaming doesn't matter much unless the rest of your PC is up for the job.