Mar-30-2023, 09:18 PM
(Mar-29-2023, 06:01 AM)buran Wrote:(Mar-29-2023, 01:43 AM)Carmazum Wrote: Python only interprets the first statement it detects as True.To be precise, it works top down until (and if) it reach aif
/elif
that is evaluated asTrue
or eventually (if present)else
. That may have effect, because some code may be executed even if the condition as whole isFalse
. In other words, code may be executed while evaluating the condition, even if the result isFalse
and the respective code block under that condition is not executed.
Simplified example
def spam(): print('Inside spam') # just to show that function has been called return False if spam(): print('spam is True') else: print('spam is False')output
Output:Inside spam spam is False
Oh, so, Python does interpret the code it finds even if it is
Did I understand correctly? Sorry if I didn't, I haven't programmed anything for a while.
Also, sorry for the late reply! (>_<)
False
. The detail is that, if it is False
, it will not execute the code inside the conditional.Did I understand correctly? Sorry if I didn't, I haven't programmed anything for a while.

Also, sorry for the late reply! (>_<)