17
Spent two hours debugging a simple loop because I forgot a colon
I was working on a Python script last night to sort a list of numbers, and my code kept throwing an 'invalid syntax' error. I mean, I checked the brackets and the indentation like three times before I finally saw I'd written 'for i in range(10)' without the colon at the end. Does anyone have a good trick for catching dumb syntax mistakes before you waste a whole evening?
2 comments
Log in to join the discussion
Log In2 Comments
terry_shah171mo ago
Oh man, I feel that! I started reading my code out loud to catch stuff like that.
4
nora101mo ago
Reading code out loud just makes you look crazy to anyone walking by.
4