python string comparison unexpected results -


this question has answer here:

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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -