What's the best way to learn to code?

I know there are a million options out there. For a beginner looking to code, or at least to understand some basics, what’s typically the best way to learn the ropes?