I have a question. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have a question.

Could anyone tell me why this code outputs False? print('a' > 'b') print("Bob" > "Dave") Output: False False

21st Feb 2022, 2:34 AM
Mustafa Sadiqi
Mustafa Sadiqi - avatar
2 Answers
+ 5
Mustafa When you compare string it compares ASCII value so here ASCII value of b is greater than a And ASCII value of D is greater than B
21st Feb 2022, 3:14 AM
A͢J
A͢J - avatar
+ 2
Got it. Thanks alot✌
21st Feb 2022, 3:15 AM
Mustafa Sadiqi
Mustafa Sadiqi - avatar