Wy „7“ > „10“ is True? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Wy „7“ > „10“ is True?

I dont get it. wy the Output is ‚seven is more‘? if "7" > "10": print(("seven is more"))

27th Feb 2020, 8:07 PM
Andreas
2 Answers
+ 6
They are compared as words are compared in a dictionary - lexically. That's because they model language mainly and are supposed to behave like language. In a dictionary, 10 would come before 7 (just as 'and' comes before 'by'), so it's smaller. If you want to know more, google the ASCII table and the unicode order.
27th Feb 2020, 8:10 PM
HonFu
HonFu - avatar
+ 1
thanks!
27th Feb 2020, 8:17 PM
Andreas