I have two variables a and b both are type string. It still works with greater than and less than operation with the assert. Shouldn’t it suppose to throw a Syntax error?
In [34]: a = '1'
In [35]: b='2'
In [36]: type(a)
Out[36]: str
In [37]: assert a<b #This works like integer or float
In [38]: assert a>b
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-38-e1202bf94274> in <module>
----> 1 assert a>b
AssertionError:
Here is second example, which is completely non-numeric string, still it works. How?
In [49]: a='bob'
In [50]: b='cat'
In [51]: assert a>b
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-51-e1606bf94274> in <module>
----> 1 assert a>b
AssertionError:
In [52]: assert a<b # How does this becomes true?