I learned to code by reading books and then writing programs to apply my knowledge.
The book depends on what language you want to start out learning. I started with C, so I read "The C Programming Language" by Brian Kerninghan and Dennis Ritchie. However, Python is generally the more popular...