18
Just tried to make a simple Python counter and it broke after 999,997 clicks
I wrote a 'for i in range(1000000)' loop to test something, but it stopped early because I accidentally put 'print(i)' inside an 'if i == 999997' block, which taught me to always check my indentation before blaming the language.
4 comments
Log in to join the discussion
Log In4 Comments
davis.olivia1mo ago
That indentation trap gets everyone at some point. Read a blog post once where a guy lost hours because a single space messed up his whole data script. Python's whitespace thing is cool for clean code but man does it bite you when you're tired. Always run a quick check on those loops before assuming the computer is broken. The machine is usually right, we just told it to do the wrong thing.
5
hannah_fisher581mo ago
What if the real problem is we're still writing code like it's on paper? I mean, our editors have color coding and auto complete but they don't really guard against indentation slips. Maybe the fix isn't being more careful, it's tools that actually see structure and warn you before you run the broken script. Idk, it just feels like we're solving the same basic mistake over and over instead of making it impossible to make.
7
grant1551mo ago
Totally agree. Linters and formatters like black for Python should be built in by default. They catch those indentation errors instantly and auto fix them. It's wild that we still manually debug spaces and tabs in 2024.
5
phoenix_martin4013d ago
Wait, hours over a single space? That's actually painful to read. Modern editors should flag that before you even save the file. We have the tech to highlight mismatched brackets instantly, so why not indentation? It seems like a basic thing to catch. Letting those tiny slips through just wastes so much time. The tools need to get smarter about the actual structure, not just the colors.
1