G
24

Watching my friend's first Python script fail because of one missing colon

My buddy just started learning to code and sent me his first real script, a simple calculator. It kept throwing an 'invalid syntax' error and he was stuck for over an hour. I looked at it and the 'if' statement on line 7 was missing the colon at the end. It's such a tiny thing, but it breaks everything. I see this all the time with people just starting out, they focus on the big ideas and miss the punctuation. How do you even learn to spot those little details without going crazy first?
2 comments

Log in to join the discussion

Log In
2 Comments
ray_patel27
Honestly what helped me was changing my editor's theme to high contrast. Tbh all that gray text made my eyes glaze over. I set keywords bright red and punctuation neon green, so a missing colon looks like a hole in the line. It feels weird at first but now my brain just expects that green blip at the end of an if statement.
2
the_miles
the_miles11d ago
Ever try reading your own code out loud? I started doing that when I kept missing quotes. You say "if a equals b" and your brain hears the colon even if it's not there. Sounds dumb but it works.
-1