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 >?

13th Sep 2018, 6:25 AM
mesenger
2 odpowiedzi
+ 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
13th Sep 2018, 6:36 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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
13th Sep 2018, 6:52 AM
Anna
Anna - avatar