mercredi 8 août 2018

if statement with constant value

Why only if statement is executed & not else statement if we write an if-else with if having constant value. For example this code in python

x=5
if 5:
 print("hello 5")
else:
 print("bye")

Also the point to be noted is that in second line even if I replace 5 with 500 or any number, if statement will be only executed.Can anyone please explain.

Aucun commentaire:

Enregistrer un commentaire