Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

equality operator with tuple: 'a', 'b' == ('a', 'b')

A tuple can be made without parenthesis.

t1 = 'a', 'b'
t2 = ('a', 'b')
t1 == t2

Output:

True

But when tried this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

'a', 'b' == ('a', 'b')

Output:

('a', False)

Can someone explain the Output in the second part?

>Solution :

, as a tuple operator has extremely low precedence. This means that if you don’t put parentheses, it will be one of the last operators to be grouped. So, 'a', 'b' == ('a', 'b') is not ('a', 'b') == ('a', 'b'), but rather 'a', ('b' == ('a', 'b')).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading