- 1

x = 4 if x == 5: print("Yes") else: print("No")

why if x==5 not x=5

22nd Dec 2016, 12:38 PM
SealCLi
SealCLi - avatar
4 odpowiedzi
+ 11
You can't use = in if statement becouse it means assing. You need use == becouse it means is it equal to?.
22nd Dec 2016, 6:22 PM
Aydin
+ 6
= is to assign a variable == is to compare variables
22nd Dec 2016, 12:39 PM
Kamil
Kamil - avatar
+ 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 =.
22nd Dec 2016, 12:45 PM
cat
cat - avatar
+ 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
10th Feb 2017, 3:03 PM
Mubbashar Ahmad Nazar
Mubbashar Ahmad Nazar - avatar