F
32

Vent: I spent a whole day debugging because I kept mixing up = and ==

I was writing a simple 'if' statement in Python to check a user's age, and my code kept skipping the check even when the input was wrong. My friend looked at it and instantly saw I'd written 'if age = 18' instead of 'if age == 18'. That single equal sign was assigning the value, not comparing it. Has anyone else had a similar 'aha' moment with a tiny syntax error?
3 comments

Log in to join the discussion

Log In
3 Comments
the_susan
the_susan5d ago
How is that not the first thing you check?
4
roberts.leo
My coding teacher said syntax errors cause 90% of beginner frustration.
4
margaretramirez
Spent an hour once because I had a comma instead of a colon in a dict. Felt so dumb.
3