0
Confused with my code
I have the following code written for an "if" statement if True: x = "hello" print(x) else: y = "goodbye" print(y) Whatever I enter in after the "y" statement I get a result of hello or true. Even after entering 2 != 2 I get true. Could someone explain why thing is to me? I feel as if this is because of how I have the code written, if anyone could help I would appreciate it.
4 Answers
+ 1
if condition:
statements
else:
statements
If the condition is True then if statements will execute otherwise else statements will execute
In your case the condition is always true so if will execute
Just make the condition to False or 0 then else would execute
+ 1
You missed a simple thing. True is not a condition. it is a answer of condition. if statement will execute if the result of condition is true. so it executes as you defined it already. use conditional instead.
+ 1
@Iqbal Mohammad Rhidwan
check out https://www.quora.com/How-can-I-make-web-apps-in-JUMP_LINK__&&__Python__&&__JUMP_LINK-without-using-any-frameworks
0
@manoj. is there any way to use python instead of php in developing website without framework.?