+ 1

How is x < y ???

x = 'apircot' y = 'banana' if (x < y) and (x != 'apple'): print(' probably apircot')

21st Sep 2019, 12:48 PM
Temitayo Shorunke
Temitayo Shorunke - avatar
4 odpowiedzi
+ 3
Python compares string lexicographically i.e using ASCII value of the characters. the ASCII value of the start character of x variable is 'a' = 95 and the ASCII value of the start character of y variable is 'b' = 96 So x < y is true
21st Sep 2019, 12:52 PM
Phurinat Puekkham
Phurinat Puekkham - avatar
+ 3
This is also similar to the ordering of words in a dictionary.
21st Sep 2019, 1:10 PM
Sonic
Sonic - avatar
+ 1
thanks for all the reposes guys
24th Sep 2019, 5:30 AM
Temitayo Shorunke
Temitayo Shorunke - avatar