💡
13
c/coding-for-beginners•corablackcorablack•22d ago

Just got my first Python script to actually work after 3 days of errors

I was messing with a simple loop to print numbers, but it kept running forever until I realized I forgot to increment my counter variable. What's a basic mistake that tripped you up when you were starting?
3 comments

Log in to join the discussion

Log In
3 Comments
paige331
paige33122d ago
Actually an infinite loop can be a big deal, it can lock up your whole system if you're not careful. Early on I kept mixing up the assignment operator with the comparison operator. I'd write "if x = 5" instead of "if x == 5" and it would just assign the value every time, breaking my logic completely. The error messages didn't always make it clear either.
8
mark_carr7
mark_carr722d ago
Paige is totally right about those assignment bugs, they're the worst. The loop itself might be easy to stop in a simple script, but if that logic is buried in a bigger system it can cause real havoc. I've seen a bad loop in a server process eat up all the memory and take down other apps. It's not just about forgetting i++, it's about the whole program logic going sideways because of one wrong character.
3
ellis.faith
ellis.faith22d agoProlific Poster
Actually running forever" sounds like a big deal but it's just a loop. You can always stop the program. Forgetting to increment a counter is like the most basic thing they warn you about in tutorials.
3