python string comparison unexpected results -
this question has answer here:
- compare 2 python strings contain numbers 5 answers
>>> '1.2.3'>'1.1.5' true >>> '1.1.3'>'1.1.5' false >>> '1.1.5'>'1.1.5' false >>> '1.1.7'>'1.1.5' true >>> '1.1.9'>'1.1.5' true >>> '1.1.10'>'1.1.5' false >>> '1.2'>'1.1.5' true >>> '1.2.9'>'1.1.5' true >>> '1.2.10'>'1.1.5' true
hi,
i trying compare 2 strings shown above. first of all, surprised python comparing strings of numbers. firstly thought compare lengths, different values it's giving exact values , astonished. but, '1.1.10' > '1.1.5' it's false... don't know why.... can help...
a = '1.1.10' b = '1.1.5' a, b in zip(a, b): print(ord(a), ord(b), > b)
49 49 false
46 46 false
49 49 false
46 46 false
49 53 false
Comments
Post a Comment