Skip to content Skip to sidebar Skip to footer

What's The Difference Between (1,) And (1) In Python

As stated in the title, I found that (1) and (1,) are different. But what's the difference of them? In[39]: (1) == (1,) Out[39]: False

Solution 1:

Try this to convince yourself:

>>> type((1))
<type 'int'>
>>> type((1,))
<type 'tuple'>

The following identity checks may provide you with further insight into the differences:

>>> (1) is 1
True
>>> (1,) is 1
False

Solution 2:


Post a Comment for "What's The Difference Between (1,) And (1) In Python"