+ 1
print("java">"javascript") in python prints false
can u explain me why does this happen on what basis does it compare words
2 Respuestas
+ 10
It's true that Java < Javascript. Lol...Jk... ^^
Jokes aside,
Python compares strings on the basis of their ASCII values. Hence, when the code -
python ("java" > "javascript")
executes.... The compiler checks every letter. First it checks "j" , as both the sides have "j" it jumps to the second letter .. The second is also same , so as the third and fourth too....The fifth letter doesn't exist in the word "java" but it does in "javascript". Hence it evaluates that to false.
Some more examples
print("b" > "a")
=> True
print("A" > "a")
=> False
+ 1
thanks man