0
What happens when two lists are compared in Python?
I have two lists which contain some numbers, different in each list. What happens when I compare them using < or >?
2 Answers
+ 5
Lexographical comparison would occur, much like how strings are compared, or how terms are ordered in a dictionary. For instance,
[1,2,3] > [1,2,2] #true
[1,2,3] > [1,2,2,4] #true
[1,2] > [1,2,3] #false
+ 3
a or b will return
- a if list a is not empty
- b if list a is empty and list b isn't
- [] if both list a and list b are empty