- 1
x = 4 if x == 5: print("Yes") else: print("No")
why if x==5 not x=5
4 Antworten
+ 11
You can't use = in if statement becouse it means assing. You need use == becouse it means is it equal to?.
+ 6
= is to assign a variable
== is to compare variables
+ 2
in programming. '=' means assigning something. and '==' means "equal to" or " is it equal to?". for any condition operation we use '==' and assigning something we use =.
+ 1
= is assignment symbol for assinging the value of a variable in the memory like x=3 mean varibale x has value of 3 assigned in memory. while == is an equal operator like if we want 2+3 is equal to 5 then we will write 2+3== 5 and