In python, is there a difference between say:
if text == 'sometext': print(text) if text == 'nottext': print("notanytext")
and
if text == 'sometext': print(text) elif text == 'nottext': print("notanytext")
Just wondering if multiple if
s could cause any unwanted problems and if it would be better practice to use elif
s.
Advertisement
Answer
Multiple if’s means your code would go and check all the if conditions, where as in case of elif, if one if condition satisfies it would not check other conditions..