Question about the difference between '=' and '==' in Python
I've been helping a friend learn Python basics, and I keep seeing them mix up the single equals sign and the double equals sign. They'd write something like 'if x = 5:' and get a syntax error. The single '=' is for putting a value into a variable, like naming a box. The double '==' is for checking if two things are the same, like asking a question. It matters because one makes your code run and the other makes it stop. I figured this out after their third script crashed in a row, and we had to go line by line. It's a tiny thing that causes big headaches when you're starting. Has anyone else found a good way to explain this to new coders?
Disagree with making it such a big deal. Beginners mix them up because the difference feels arbitrary at first. Just let them hit the error and learn from it, that's how it sticks.
My friend spent two hours debugging a script because he wrote "if user_password = 'secret123'" in a login check. The whole thing just assigned the string and returned True every time. I told him the single equals is you giving the variable a new name tag, double equals is you asking if it already has that name tag. He still side-eyes me when we code together.