Conditional Statements

a = 5
b = 10
if b < a:
print(“a is greater than b”)
elif a == b:
b = 5
print(“a and b are equal”)
print(“b is greater than a”)

The solution to the above code is “b is greater than a”.

Help me understand on the elif we have mentioned b=5, why wouldn’t the initial b value of 10 now changed to 5 and provided current value of b is 5, then the solution would be “a and b are equal”.

Hello @mahesh.kumar.sridhar,
Because this line(b=5) isn’t executed because its condition(a == b) isn’t correct so simply the condition isn’t executed → what under the condition also isn’t exected

You didn’t intended if conditional statement

Hello @nitinshukla7944
Thanks for sharing!