Why can't we use '=' operator in these statements ? | SoloLearn: Learn to code for FREE!

0

Why can't we use '=' operator in these statements ?

When I tried that, it gave me a syntax error

3/28/2020 4:02:08 AM

Ahsen Mirza

2 Answers

New Answer

+1

hi, what language do you use (python, JS...) ? basic syntax is usually : if (... some condition ...) {...code to execute if True...} ; in condition you can use something like : x==1 (comparaison operator) it's better than : x=1 (assignation operator who will always true or always false)

+1

= is for assign the value to a variable, while == is to compare. In an if statement, you should use == instead of =.