# How to get started learning to code

Hi I’m Emmanuel,

I have been learning Python and basic programming skills on and off for the past year.
At first, I thought I was getting the hang of it, but after a while, when I saw people on YouTube make games or explain how clouds work, it made me wonder how I could ever get to that point. I tried to solve problems on Leetcode or HackerRant, but I always had to look for the answer because I didn’t fully understand how the problem was solved. I’m really interested in this area of work and learning, but I feel like I’ve been going about it all wrong. Does anyone have any tips or tricks that can help me learn how to code in a new way?

Steady, incremental, steps. I can pretty much guarantee you that nobody ever just woke up one day suddenly understanding every aspect of {insert programming language / platform / technique here} in intricate detail.

Solving any problem with code is two-fold, and in the four-and-a-bit years I’ve been here I’ve seen many learners focus solely on one part of it.

Let’s say hypothetically that you’re trying to solve this kata, from Codewars:

The two parts of solving this are as follows:

1. Deduce the algorithm for solving the problem.
2. Implement that algorithm as code.

The important part of #1 - which many people overlook - is that code is irrelevant to begin with. Solve the problem as a human - whether that’s in your head, with pen and paper, or some other way doesn’t matter. Work out the process - because “algorithm” is just a fancy word for “repeatable process” - that you need to follow to complete the task.

Once you have those steps firmly in your grasp, only then should you move to implement those steps in code. This is because you’ll likely find that your “human friendly” process contains hints on how to solve the problem with code.

Sticking with this example:

1. Let’s consider the case where `n = 3`.
2. Let’s call the exponent `e`, and set it to `0`.
3. Calculate 2 to the power e - `2 ^ e` - and record the value. `[1]`.
4. Repeat the process for every integer exponent between 0 and n inclusive.

Notice that I’ve highlighted certain words in bold… which may suggest potential constructs or other relevant data which could help in coding the required function.

This is a somewhat simplistic example, but largely I’ve found that the process is the same for more complex tasks that I’ve attempted myself in some personal projects. If I don’t have a solid grasp on the process I’m attempting to follow without code being involved, then largely I struggle to implement that process in code.

Fundamentally, this is because all your code is doing is telling the computer how to complete a task. If you don’t know how to complete that task yourself, how are you going to tell the computer - or another person, etc - how to do it?

To provide a bit more general advice, I would encourage you to spend time getting familiar with the standard library in Python. Get familiar with how to make, and break, the core constructs of the language. Get comfortable with how a `for` loop works, then make it go backwards, or make it ignore every 4th item, or whatever.

Even the most trivial looking of practice tasks is still that: practice. Do a little bit every day, if you can, even if it’s just a few minutes revisiting something you did earlier in the week.

1 Like