- 2
What is the output of this code? print(âheyâ < âhayâ)
why
3 Answers
+ 3
> What is the output?
You can find it by running the code on sololearn playground. Have you tried it?
> Why is this the output?
Alphabetic ordering.
đPLEASE TAG "python" NOT "#why"
+ 2
It is comparing 2 strings lexiographycally..
Each of character of first string is compared with corresponding second string character.
It returns False. "hey" is greater than "hay" since 'e' > 'a' is True. (compared by ascii values).
'e' < 'a' false so "hey" < "hay" False.
hope it helps......
add relevant tags..
+ 2
print("a"<"b") #True
print("z">"za") #False
print("hello">="hello")#True