I am learning hash table and BST. I got confused when I compared (True) with True I have got True as an answer. But if I compare (True, True) == True, True I,m getting set: (False, True). Why it is happening so?
Asked
Active
Viewed 121 times
-1

oneku
- 9
- 4
-
1Note that there are no sets or "hashsets" involved here at all. You should also post text as text, not as screenshot. – deceze Nov 15 '22 at 15:55
1 Answers
0
The equality expression is comparing the tuple on the left hand side with the first instance of True
only. It looks like there should be pair-wise comparisons, but that is not happening. The last line here is how python interpreter sees this expression, which is:
- the comparison of a tuple to a single value
- the integer 123
- the string "Dog"
>>> (True, True) == True, True
(False, True)
>>> (True, True) == True, 123, 'Dog'
(False, 123, 'Dog')
>>> ((True, True) == True), 123, 'Dog'
(False, 123, 'Dog')

AirSquid
- 10,214
- 2
- 7
- 31