🎙️
20
c/coding-for-beginnersthe_milathe_mila28d agoMost Upvoted

Spent 6 months writing Python loops wrong until a coworker looked at my screen

I was using a for loop to process a list of customer orders. Kept getting weird output. Turns out I was modifying the list while iterating over it. My coworker Jen walked by, saw it, and just said "you're deleting the chair you're sitting on." Took me a minute to get it. Has anyone else had a basic coding habit they didn't know was broken for way too long?
3 comments

Log in to join the discussion

Log In
3 Comments
stellaa69
stellaa6928d ago
oh man, that phrasing is perfect - deleting the chair you're sitting on. i spent like a year adding stuff to a list while looping through it and wondering why it never ended. felt so dumb when someone pointed it out lol
7
mark_price
mark_price28d ago
3 years ago I spent a whole weekend debugging a script that kept crashing because I was deleting items from a list while iterating over it. @stellaa69 what made you finally realize what was going on? Was it a rubber duck or did someone actually walk you through it?
1
drew_bennett24
and the worst part is once you see it you can't unsee it. every time i look at old code now i'm like how did i not notice that, it's so obvious. it's one of those things where your brain just sets a pattern and won't look at it different until someone else breaks the spell. honestly makes me wonder what other dumb stuff i'm doing right now that i just haven't realized yet. kinda humbling when you think about it.
0