- 2
What is the output of this code? print(“hey” < “hay”)
why
3 ответов
+ 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