Is there any logic behind it?
>>>'a' and 'b' and 'c'
'c'
>>>'a' or 'b' or 'c'
'a'
Is there any logic behind it?
>>>'a' and 'b' and 'c'
'c'
>>>'a' or 'b' or 'c'
'a'
Yes, there is logic, Boolean logic.
Boolean operators in Python are lazy, so they return the first value that proves that the entire statement is True.
'a' and 'b' and 'c'
returns c
because it's the first time it can prove the whole statement is True.
'a' or 'b' or 'c'
returns a
because it's True, so the rest of the values in the statement don't matter.