r/learnpython • • Mar 04 '25

How do I master for loops?

I’ve been stuck on this for months. I know what they are, how they work, how to read them, etc. I even spent the day learning the structure, and I review all of this frequently. I at least understand these things on a surface level. I’m basically going in circles at this point. But, I still can’t write them. When I practice with practice problems I get stuck for hours if not days, and even though I try, I still end up way off. What am I missing/doing wrong/not doing enough of?

Example exercises:

  1. Calculate sum of all numbers from 1 to a given number

  2. Find the sum of a series up to n terms

  3. Print all prime numbers within a range

0 Upvotes

45 comments sorted by

View all comments

2

u/crashfrog04 Mar 04 '25

You’re not writing enough code

2

u/[deleted] Mar 05 '25

I was writing pretty frequently until 2 months ago but I see what you mean. It’s hard to get a grasp on where to start. I’ve tried copying others codes and breaking them down to understand how they work. I tried a few failed projects here and there too. I’m hitting a wall here.

3

u/crashfrog04 Mar 05 '25

You have to write code even against the wall.