Coding is a mindset. It clicks with some people and not with others.
Yes, almost anyone can learn the basic concepts and structures, but to be good at it, you need to make the leap into seeing problems in terms of those concepts.
If you liked proofs in high school geometry, you will probably be good at coding. Once I was able I to make that connection, geometry proofs were easy.
But I’ve met some very smart people who just don’t have the mindset. They are good at other things but they just never caught on to coding.
Just my take from 40 years of coding, both professionally and personally.
I think it’s a bit more than that. I compared it to geometry proofs because it requires you to apply concepts to get from point A to point B. Yes, you can blindly follow directions and possibly get through a class, but to be really good you need to have the mindset necessary to logically solve problems. That is more than just following directions. That’s more akin to cooking and just following a recipe vs creating a new dish.