Reputation: 915
I was comparing two tuples for equality using below expression.
>>> (1, 2, 3) == 1, 2, 3
(False, 2, 3)
I was expecting it will give True
. However, below expression works as expected.
>>> a = (1, 2, 3)
>>> b = 1, 2, 3
>>>
>>> a == b
True
I am unable to understand this behavior. I am using Python 3.6.8
Upvotes: 2
Views: 61
Reputation: 38892
The (1, 2, 3) == 1, 2, 3
is defining a tuple where the first element is the value of the expression (1, 2, 3) == 1
, which is False.
Upvotes: 3