O
2

Back when I started, I spent a whole weekend trying to get my first loop to work right.

The problem was I kept getting a list index error in Python, and I couldn't figure out why my loop stopped too early. After about six hours of staring at it, I found a tip in an old forum post about using 'len(my_list) - 1'. That was the trick. It finally clicked that I was trying to reach one item past the end. Has anyone else had a simple fix like that for a loop that just wouldn't behave?
3 comments

Log in to join the discussion

Log In
3 Comments
tessa_clark74
Totally get that feeling when the answer is right there but you just can't see it! It reminds me of putting something down in your own house and then spending forever looking for it. The solution is often one small step back from where you're frantically searching. Those off-by-one errors are the worst because they feel so obvious after you find them. Makes you want to laugh and cry at the same time after all that struggle.
1
margaretm23
Used to think those moments meant I wasn't paying enough attention. Reading what @tessa_clark74 said really clicked for me though. It's not about being careless, it's how our brains work when we're stuck on one path. That feeling of the answer being just out of reach is actually part of figuring it out. Now I see it as my brain working hard, not failing. Makes the whole process less frustrating somehow.
4
anthonymurray
Sometimes you just need to walk away for a minute.
3