Can someone explain to me what is happening here?
>>> [] > 0
True
>>> [] > 0.1
True
>>> [] < 0
False
>>> [] < 0.1
False
>>> [] > 'string'
False
>>> [] < 'string'
True
Why and how does this work?
Can someone explain to me what is happening here?
>>> [] > 0
True
>>> [] > 0.1
True
>>> [] < 0
False
>>> [] < 0.1
False
>>> [] > 'string'
False
>>> [] < 'string'
True
Why and how does this work?
So you are using Python2, where you can compare between list and strings and numbers. This helps to sort them out.
Python2
[0]>1
=> True
However since Python3 this has been removed.
Python3
[0]>1
Traceback (most recent call last):
File "python", line 1, in <module>
TypeError: unorderable types: list() > int()
Hope that explains, why list has been made to be greater than number is purely subjective and depends on the creators.