Trying to teach my grandchildren (and myself) python I slide into surprises all the time. The last one:
So what does and or or really mean, what kind of results can it deliver, when can I expect an exception?
Thanks in advance for any tip
H
>>> x=3 >>> y=5 >>> x and y 5 >>> y and x 3 >>> x or y 3 >>> y or x 5 >>> x='7' >>> x and y 5 >>> y and x '7' >>> type(x and y) <class 'int'> >>> type(y and x) <class 'str'>You will get similar results with or.
So what does and or or really mean, what kind of results can it deliver, when can I expect an exception?
Thanks in advance for any tip
H